empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1180729 [2/2] - in /incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db: ./ derby/ h2/ hsql/ mysql/ oracle/ postgresql/ sqlserver/
Date Sun, 09 Oct 2011 22:21:32 GMT
Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java?rev=1180729&r1=1180728&r2=1180729&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
Sun Oct  9 22:21:31 2011
@@ -21,29 +21,17 @@ package org.apache.empire.db.postgresql;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.GregorianCalendar;
-import java.util.Iterator;
 
-import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.DataType;
 import org.apache.empire.db.DBCmdType;
-import org.apache.empire.db.DBColumn;
 import org.apache.empire.db.DBCommand;
-import org.apache.empire.db.DBCommandExpr;
+import org.apache.empire.db.DBDDLGenerator;
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBDatabaseDriver;
 import org.apache.empire.db.DBDriverFeature;
-import org.apache.empire.db.DBExpr;
-import org.apache.empire.db.DBIndex;
 import org.apache.empire.db.DBObject;
-import org.apache.empire.db.DBRelation;
 import org.apache.empire.db.DBSQLScript;
-import org.apache.empire.db.DBTable;
-import org.apache.empire.db.DBTableColumn;
-import org.apache.empire.db.DBView;
 import org.apache.empire.db.exceptions.InternalSQLException;
-import org.apache.empire.exceptions.InvalidArgumentException;
-import org.apache.empire.exceptions.NotImplementedException;
-import org.apache.empire.exceptions.NotSupportedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -130,6 +118,8 @@ public class DBDatabaseDriverPostgreSQL 
     }
     
     private String databaseName;
+
+    private DBDDLGenerator<?> ddlGenerator = null; // lazy creation
     
     /**
      * Constructor for the PostgreSQL database driver.<br>
@@ -434,83 +424,6 @@ public class DBDatabaseDriverPostgreSQL 
         }
         return val;
     }
-    
-    /**
-     * @see DBDatabaseDriver#getDDLScript(DBCmdType, DBObject, DBSQLScript)  
-     */
-    @Override
-    public void getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
-    {
-        // The Object's database must be attached to this driver
-        if (dbo==null || dbo.getDatabase().getDriver()!=this)
-            throw new InvalidArgumentException("dbo", dbo);
-        // Check Type of object
-        if (dbo instanceof DBDatabase)
-        { // Database
-            switch (type)
-            {
-                case CREATE:
-                    createDatabase((DBDatabase) dbo, script);
-                    return;
-                case DROP:
-                    dropObject(((DBDatabase) dbo).getSchema(), "DATABASE", script);
-                    return;
-                default:
-                    throw new NotImplementedException(this, "getDDLScript."+dbo.getClass().getName()+"."+String.valueOf(type));
-            }
-        } 
-        else if (dbo instanceof DBTable)
-        { // Table
-            switch (type)
-            {
-                case CREATE:
-                    createTable((DBTable) dbo, script);
-                    return;
-                case DROP:
-                    dropObject(((DBTable) dbo).getName(), "TABLE", script);
-                    return;
-                default:
-                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName()
+ "." + type);
-            }
-        } 
-        else if (dbo instanceof DBView)
-        { // View
-            switch (type)
-            {
-                case CREATE:
-                    createView((DBView) dbo, script);
-                    return;
-                case DROP:
-                    dropObject(((DBView) dbo).getName(), "VIEW", script);
-                    return;
-                default:
-                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName()
+ "." + type);
-            }
-        } 
-        else if (dbo instanceof DBRelation)
-        { // Relation
-            switch (type)
-            {
-                case CREATE:
-                    createRelation((DBRelation) dbo, script);
-                    return;
-                case DROP:
-                    dropObject(((DBRelation) dbo).getName(), "CONSTRAINT", script);
-                    return;
-                default:
-                    throw new NotImplementedException(this, "getDDLScript." + dbo.getClass().getName()
+ "." + type);
-            }
-        } 
-        else if (dbo instanceof DBTableColumn)
-        { // Table Column
-            alterTable((DBTableColumn) dbo, type, script);
-            return;
-        } 
-        else
-        { // dll generation not supported for this type
-            throw new NotSupportedException(this, "getDDLScript() for "+dbo.getClass().getName());
-        }
-    }
 
     /**
      * Overridden. Returns a timestamp that is used for record updates created by the database
server.
@@ -525,415 +438,16 @@ public class DBDatabaseDriverPostgreSQL 
         return new java.sql.Timestamp(cal.getTimeInMillis());
     }
 
-    /*
-     * return the sql for creating a Database
-     */
-    protected boolean createDatabase(DBDatabase db, DBSQLScript script)
-    {    	
-        // Create all Sequences
-        Iterator<DBTable> seqtabs = db.getTables().iterator();
-        while (seqtabs.hasNext())
-        {
-            DBTable table = seqtabs.next();
-            Iterator<DBColumn> cols = table.getColumns().iterator();
-            while (cols.hasNext())
-            {
-                DBTableColumn c = (DBTableColumn) cols.next();
-                if (c.getDataType() == DataType.AUTOINC)
-                {
-                    createSequence(db, c, script);
-                }
-            }
-        }
-    	
-        // Create all Tables
-        Iterator<DBTable> tables = db.getTables().iterator();
-        while (tables.hasNext())
-        {
-            createTable(tables.next(), script);
-        }
-        // Create Relations
-        Iterator<DBRelation> relations = db.getRelations().iterator();
-        while (relations.hasNext())
-        {
-            createRelation(relations.next(), script);
-        }
-        // Create Views
-        Iterator<DBView> views = db.getViews().iterator();
-        while (views.hasNext())
-        {
-            createView(views.next(), script);
-        }
-        // Done
-        return true;
-    }
-    
-    protected String createSequenceName(DBTableColumn c){
-    	 Object defValue = c.getDefaultValue();
-         return (defValue != null) ? defValue.toString() : c.toString();
-    }
-    
-    /**
-     * Returns true if the sequence has been created successfully.
-     * 
-     * @return true if the sequence has been created successfully
-     */
-    protected void createSequence(DBDatabase db, DBTableColumn c, DBSQLScript script)
-    {
-    	String seqName = createSequenceName(c);
-        // createSQL
-        StringBuilder sql = new StringBuilder();
-        sql.append("-- creating sequence for column ");
-        sql.append(c.getFullName());
-        sql.append(" --\r\n");
-        sql.append("CREATE SEQUENCE ");
-        db.appendQualifiedName(sql, seqName, detectQuoteName(seqName));
-        
-//        create sequence foo_id_seq;
-//        select setval('foo_id_seq', (select max(id) from foo));
-
-        
-        sql.append(" INCREMENT BY 1 START WITH 1 MINVALUE 0");
-        // executeDLL
-        script.addStmt(sql);
-    }
-    
-    /**
-     * Returns true if the table has been created successfully.
-     * 
-     * @return true if the table has been created successfully
-     */
-    protected void createTable(DBTable t, DBSQLScript script)
-    {
-        StringBuilder sql = new StringBuilder();
-        sql.append("-- creating table ");
-        sql.append(t.getName());
-        sql.append(" --\r\n");
-        sql.append("CREATE TABLE ");
-        t.addSQL(sql, DBExpr.CTX_FULLNAME);
-        sql.append(" (");
-        boolean addSeparator = false;
-        Iterator<DBColumn> columns = t.getColumns().iterator();
-        while (columns.hasNext())
-        {
-            DBTableColumn c = (DBTableColumn) columns.next();
-            sql.append((addSeparator) ? ",\r\n   " : "\r\n   ");
-            if (appendColumnDesc(c, sql, false)==false)
-                continue; // Ignore and continue;
-            addSeparator = true;
-        }
-        // Primary Key
-        DBIndex pk = t.getPrimaryKey();
-        if (pk != null)
-        { // add the primary key
-            sql.append(", PRIMARY KEY (");
-            addSeparator = false;
-            // columns
-            DBColumn[] keyColumns = pk.getColumns();
-            for (int i = 0; i < keyColumns.length; i++)
-            {
-                sql.append((addSeparator) ? ", " : "");
-                keyColumns[i].addSQL(sql, DBExpr.CTX_NAME);
-                addSeparator = true;
-            }
-            sql.append(")");
-        }
-        sql.append(")");
-        // Comment?
-        String comment = t.getComment();
-        if (StringUtils.isNotEmpty(comment))
-        {   // Add the table comment
-            sql.append(" COMMENT = '");
-            sql.append(comment);
-            sql.append("'");
-        }
-        // Create the table
-        script.addStmt(sql);
-        // Create other Indexes (except primary key)
-        Iterator<DBIndex> indexes = t.getIndexes().iterator();
-        while (indexes.hasNext())
-        {
-            DBIndex idx = indexes.next();
-            if (idx == pk || idx.getType() == DBIndex.PRIMARYKEY)
-                continue;
-
-            // Cretae Index
-            sql.setLength(0);
-            sql.append((idx.getType() == DBIndex.UNIQUE) ? "CREATE UNIQUE INDEX " : "CREATE
INDEX ");
-            appendElementName(sql, idx.getName());
-            sql.append(" ON ");
-            t.addSQL(sql, DBExpr.CTX_FULLNAME);
-            sql.append(" (");
-            addSeparator = false;
-
-            // columns
-            DBColumn[] idxColumns = idx.getColumns();
-            for (int i = 0; i < idxColumns.length; i++)
-            {
-                sql.append((addSeparator) ? ", " : "");
-                idxColumns[i].addSQL(sql, DBExpr.CTX_NAME);
-                addSeparator = true;
-            }
-            sql.append(")");
-            // Create Index
-            script.addStmt(sql);
-        }
-    }
-    
-    /**
-     * Appends a table column definition to a ddl statement
-     * http://www.postgresql.org/docs/8.3/static/datatype.html
-     * 
-     * @param c the column which description to append
-     * @param sql the sql builder object
-     * @param alter is this for an alter statement
-     * 
-     * @return true if the column was successfully appended or false otherwise
-     */
-    protected boolean appendColumnDesc(DBTableColumn c, StringBuilder sql, boolean alter)
-    {
-        // Append name
-        c.addSQL(sql, DBExpr.CTX_NAME);
-        if(alter)
-        {
-        	sql.append(" TYPE ");
-        }else
-        {
-        	sql.append(" ");
-        }
-        switch (c.getDataType())
-        {
-            case INTEGER:
-            {
-                int size = (int) c.getSize();
-                if (size >= 8) {
-                    sql.append("BIGINT");
-                } else {
-                    sql.append("INT");
-                }
-//                if (size>0)
-//                {   // Set Integer length
-//                    sql.append("(");
-//                    sql.append(String.valueOf(size));
-//                    sql.append(")");
-//                }
-                break;
-            }
-            case AUTOINC:
-            { // Auto increment
-                int size = (int) c.getSize();
-                if (size >= 8) {
-                    sql.append("BIGSERIAL");
-                } else {
-                    sql.append("SERIAL");
-                }
-
-                //String seqName = createSequenceName(c);
-                //sql.append(" DEFAULT nextval('"+seqName+"')");
-                break;
-            }
-            case TEXT:
-            { // Check fixed or variable length
-                int size = Math.abs((int) c.getSize());
-                if (size == 0)
-                    size = 100;
-                sql.append("VARCHAR(");
-                sql.append(String.valueOf(size));
-                sql.append(")");
-            }
-                break;
-            case CHAR:
-            { // Check fixed or variable length
-                int size = Math.abs((int) c.getSize());
-                if (size == 0)
-                    size = 1;
-                sql.append("CHAR(");
-                sql.append(String.valueOf(size));
-                sql.append(")");
-            }
-                break;
-            case DATE:
-                sql.append("DATE");
-                break;
-            case DATETIME:
-                sql.append("TIMESTAMP");
-                break;
-            case BOOL:
-                sql.append("BOOLEAN");
-                break;
-            case FLOAT:
-                sql.append("DOUBLE PRECISION");
-                break;
-            case DECIMAL:
-            { // Decimal
-                sql.append("DECIMAL(");
-                int prec = (int) c.getSize();
-                int scale = (int) ((c.getSize() - prec) * 10 + 0.5);
-                // sql.append((prec+scale).ToString());sql.append(",");
-                sql.append(String.valueOf(prec));
-                sql.append(",");
-                sql.append(String.valueOf(scale));
-                sql.append(")");
-            }
-                break;
-            case CLOB:
-                sql.append("TEXT");
-                break;
-            case BLOB:
-                sql.append("BYTEA");
-                break;
-            case UNIQUEID:
-                // emulate using java.util.UUID
-                sql.append("CHAR(36)");
-                break;
-            case UNKNOWN:
-                log.warn("Cannot append column of Data-Type 'UNKNOWN'");
-                return false;
-        }
-        // Default Value
-        if (isDDLColumnDefaults() && !c.isAutoGenerated() && c.getDefaultValue()!=null)
-        {   sql.append(" DEFAULT ");
-            sql.append(getValueString(c.getDefaultValue(), c.getDataType()));
-        }
-        // Nullable
-        if (c.isRequired() ||  c.isAutoGenerated())
-            sql.append(" NOT NULL");
-        // Done
-        return true;
-    }
-
-    /**
-     * Returns true if the relation has been created successfully.
-     * 
-     * @return true if the relation has been created successfully
-     */
-    protected void createRelation(DBRelation r, DBSQLScript script)
-    {
-        DBTable sourceTable = (DBTable) r.getReferences()[0].getSourceColumn().getRowSet();
-        DBTable targetTable = (DBTable) r.getReferences()[0].getTargetColumn().getRowSet();
-
-        StringBuilder sql = new StringBuilder();
-        sql.append("-- creating foreign key constraint ");
-        sql.append(r.getName());
-        sql.append(" --\r\n");
-        sql.append("ALTER TABLE ");
-        sourceTable.addSQL(sql, DBExpr.CTX_FULLNAME);
-        sql.append(" ADD CONSTRAINT ");
-        appendElementName(sql, r.getName());
-        sql.append(" FOREIGN KEY (");
-        // Source Names
-        boolean addSeparator = false;
-        DBRelation.DBReference[] refs = r.getReferences();
-        for (int i = 0; i < refs.length; i++)
-        {
-            sql.append((addSeparator) ? ", " : "");
-            refs[i].getSourceColumn().addSQL(sql, DBExpr.CTX_NAME);
-            addSeparator = true;
-        }
-        // References
-        sql.append(") REFERENCES ");
-        targetTable.addSQL(sql, DBExpr.CTX_FULLNAME);
-        sql.append(" (");
-        // Target Names
-        addSeparator = false;
-        for (int i = 0; i < refs.length; i++)
-        {
-            sql.append((addSeparator) ? ", " : "");
-            refs[i].getTargetColumn().addSQL(sql, DBExpr.CTX_NAME);
-            addSeparator = true;
-        }
-        // done
-        sql.append(")");
-        script.addStmt(sql);
-    }
-    
-    /**
-     * Creates an alter table dll statement for adding, modifiying or droping a column.
-     * @param col the column which to add, modify or drop
-     * @param type the type of operation to perform
-     * @param script to which to append the sql statement to
-     * @return true if the statement was successfully appended to the buffer
-     */
-    protected void alterTable(DBTableColumn col, DBCmdType type, DBSQLScript script)
-    {
-        StringBuilder sql = new StringBuilder();
-        sql.append("ALTER TABLE ");
-        col.getRowSet().addSQL(sql, DBExpr.CTX_FULLNAME);
-        switch(type)
-        {
-            case CREATE:
-                sql.append(" ADD ");
-                appendColumnDesc(col, sql, false);
-                break;
-            case ALTER:
-                sql.append(" ALTER COLUMN ");
-                appendColumnDesc(col, sql, true);
-                break;
-            case DROP:
-                sql.append(" DROP COLUMN ");
-                sql.append(col.getName());
-                break;
-        }
-        // done
-        script.addStmt(sql);
-    }
-    
-    
-
     /**
-     * Returns true if the view has been created successfully.
-     * 
-     * @return true if the view has been created successfully
-     */
-    protected void createView(DBView v, DBSQLScript script)
-    {
-        // Create the Command
-        DBCommandExpr cmd = v.createCommand();
-        if (cmd==null)
-        {   // Check whether Error information is available
-            log.error("No command has been supplied for view " + v.getName());
-            throw new NotImplementedException(this, v.getName() + ".createCommand");
-        }
-        // Make sure there is no OrderBy
-        cmd.clearOrderBy();
-
-        // Build String
-        StringBuilder sql = new StringBuilder();
-        sql.append( "CREATE VIEW ");
-        v.addSQL(sql, DBExpr.CTX_FULLNAME);
-        sql.append( " (" );
-        boolean addSeparator = false;
-        for(DBColumn c : v.getColumns())
-        {
-            if (addSeparator)
-                sql.append(", ");
-            // Add Column name
-            c.addSQL(sql, DBExpr.CTX_NAME);
-            // next
-            addSeparator = true;
-        }
-        sql.append(")\r\nAS\r\n");
-        cmd.addSQL( sql, DBExpr.CTX_DEFAULT);
-        // done
-        script.addStmt(sql.toString());
-    }
-    
-    /**
-     * Returns true if the object has been dropped successfully.
-     * 
-     * @return true if the object has been dropped successfully
+     * @see DBDatabaseDriver#getDDLScript(DBCmdType, DBObject, DBSQLScript)  
      */
-    protected void dropObject(String name, String objType, DBSQLScript script)
+    @Override
+    public void getDDLScript(DBCmdType type, DBObject dbo, DBSQLScript script)
     {
-        if (name == null || name.length() == 0)
-            throw new InvalidArgumentException("name", name);
-        // Create Drop Statement
-        StringBuilder sql = new StringBuilder();
-        sql.append("DROP ");
-        sql.append(objType);
-        sql.append(" ");
-        appendElementName(sql, name);
-        script.addStmt(sql);
+        if (ddlGenerator==null)
+            ddlGenerator = new PostgreDDLGenerator(this);
+        // forward request
+        ddlGenerator.getDDLScript(type, dbo, script); 
     }
     
 }

Added: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/PostgreDDLGenerator.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/PostgreDDLGenerator.java?rev=1180729&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/PostgreDDLGenerator.java
(added)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/PostgreDDLGenerator.java
Sun Oct  9 22:21:31 2011
@@ -0,0 +1,152 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.postgresql;
+
+import java.util.Iterator;
+
+import org.apache.empire.data.DataType;
+import org.apache.empire.db.DBColumn;
+import org.apache.empire.db.DBDDLGenerator;
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.DBExpr;
+import org.apache.empire.db.DBSQLScript;
+import org.apache.empire.db.DBTable;
+import org.apache.empire.db.DBTableColumn;
+
+public class PostgreDDLGenerator extends DBDDLGenerator<DBDatabaseDriverPostgreSQL>
+{
+    public PostgreDDLGenerator(DBDatabaseDriverPostgreSQL driver)
+    {
+        super(driver);
+        // set Oracle specific data types
+        initDataTypes();
+    }
+
+    /**
+     * sets Oracle specific data types
+     * @param driver
+     */
+    private void initDataTypes()
+    {   // Override data types
+        DATATYPE_BOOLEAN = "BOOLEAN";
+    }
+
+    @Override
+    protected boolean appendColumnDataType(DataType type, double size, DBTableColumn c, StringBuilder
sql)
+    {
+        switch (type)
+        {
+            case AUTOINC:
+            { // Auto increment
+                int bytes = Math.abs((int)size);
+                if (bytes>= 8) {
+                    sql.append("BIGSERIAL");
+                } else {
+                    sql.append("SERIAL");
+                }
+                //String seqName = createSequenceName(c);
+                //sql.append(" DEFAULT nextval('"+seqName+"')");
+                break;
+            }
+            case FLOAT:
+            {   // only use double precision
+                sql.append("DOUBLE PRECISION");
+                break;
+            }
+           default:
+                // use default
+                return super.appendColumnDataType(type, size, c, sql);
+        }
+        return true;
+    }
+    
+    @Override
+    protected void createDatabase(DBDatabase db, DBSQLScript script)
+    {
+        // Create all Sequences
+        Iterator<DBTable> seqtabs = db.getTables().iterator();
+        while (seqtabs.hasNext())
+        {
+            DBTable table = seqtabs.next();
+            Iterator<DBColumn> cols = table.getColumns().iterator();
+            while (cols.hasNext())
+            {
+                DBTableColumn c = (DBTableColumn) cols.next();
+                if (c.getDataType() == DataType.AUTOINC)
+                {
+                    createSequence(db, c, script);
+                }
+            }
+        }
+        // default processing
+        super.createDatabase(db, script);
+    }
+
+    /**
+     * Appends the DDL-Script for creating a sequence to an SQL-Script<br/>
+     * @param db the database to create
+     * @param c the column for which to create the sequence
+     * @param script the sql script to which to append the dll command(s)
+     */
+    protected void createSequence(DBDatabase db, DBTableColumn c, DBSQLScript script)
+    {
+        Object defValue = c.getDefaultValue();
+        String seqName = (defValue != null) ? defValue.toString() : c.toString();
+        // createSQL
+        StringBuilder sql = new StringBuilder();
+        sql.append("-- creating sequence for column ");
+        sql.append(c.getFullName());
+        sql.append(" --\r\n");
+        sql.append("CREATE SEQUENCE ");
+        db.appendQualifiedName(sql, seqName, detectQuoteName(seqName));
+        
+//        create sequence foo_id_seq;
+//        select setval('foo_id_seq', (select max(id) from foo));
+
+        sql.append(" INCREMENT BY 1 START WITH 1 MINVALUE 0");
+        // executeDLL
+        script.addStmt(sql);
+    }
+
+    @Override
+    protected void appendColumnDesc(DBTableColumn c, boolean alter, StringBuilder sql)
+    {
+        // Append name
+        c.addSQL(sql, DBExpr.CTX_NAME);
+        // Alter or create
+        if (alter) {
+            sql.append(" TYPE ");
+        } else {
+            sql.append(" ");
+        }
+        // Unknown data type
+        if (!appendColumnDataType(c.getDataType(), c.getSize(), c, sql))
+            return;
+        // Default Value
+        if (driver.isDDLColumnDefaults() && !c.isAutoGenerated() && c.getDefaultValue()!=null)
+        {   sql.append(" DEFAULT ");
+            sql.append(driver.getValueString(c.getDefaultValue(), c.getDataType()));
+        }
+        // Nullable
+        if (c.isRequired() ||  c.isAutoGenerated())
+            sql.append(" NOT NULL");
+    }
+    
+}
+

Propchange: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/PostgreDDLGenerator.java
------------------------------------------------------------------------------
    eol-style = native

Propchange: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/PostgreDDLGenerator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/MSSqlDDLGenerator.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/MSSqlDDLGenerator.java?rev=1180729&r1=1180728&r2=1180729&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/MSSqlDDLGenerator.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/MSSqlDDLGenerator.java
Sun Oct  9 22:21:31 2011
@@ -47,7 +47,6 @@ public class MSSqlDDLGenerator extends D
         DATATYPE_VARCHAR    = "NVARCHAR";   // variable length characters (unicode)     

         DATATYPE_DATE       = "DATETIME";
         DATATYPE_TIMESTAMP  = "DATETIME";
-        DATATYPE_BOOLEAN    = "BIT";
         DATATYPE_CLOB       = "NTEXT";
         DATATYPE_BLOB       = "IMAGE";
         DATATYPE_UNIQUEID   = "UNIQUEID";  // Globally Unique Identifier



Mime
View raw message