empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franci...@apache.org
Subject svn commit: r1061999 - in /incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db: derby/DBDatabaseDriverDerby.java postgresql/DBDatabaseDriverPostgreSQL.java
Date Fri, 21 Jan 2011 20:07:36 GMT
Author: francisdb
Date: Fri Jan 21 20:07:36 2011
New Revision: 1061999

URL: http://svn.apache.org/viewvc?rev=1061999&view=rev
Log:
EMPIREDB-94 Postge and Derby bigint, patch by Eike Kettner

Modified:
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/derby/DBDatabaseDriverDerby.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/derby/DBDatabaseDriverDerby.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/derby/DBDatabaseDriverDerby.java?rev=1061999&r1=1061998&r2=1061999&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/derby/DBDatabaseDriverDerby.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/derby/DBDatabaseDriverDerby.java
Fri Jan 21 20:07:36 2011
@@ -18,10 +18,6 @@
  */
 package org.apache.empire.db.derby;
 
-import java.sql.Connection;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-
 import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.DataType;
@@ -42,6 +38,10 @@ import org.apache.empire.db.DBTableColum
 import org.apache.empire.db.DBView;
 import org.apache.empire.db.oracle.DBDatabaseDriverOracle.BooleanType;
 
+import java.sql.Connection;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+
 
 /**
  * This class provides support for the Derby database system.
@@ -509,23 +509,32 @@ public class DBDatabaseDriverDerby exten
         {
             case INTEGER:
             { // Integer type
-                sql.append("INT");
                 int size = (int)c.getSize();
-                if (size>0)
-                {   // Set Integer length
-                    sql.append("(");
-                    sql.append(String.valueOf(size));
-                    sql.append(")");
+                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
-                sql.append("INT");
-                if (useSequenceTable==false)
+                int size = (int)c.getSize();
+                if (size >= 8) {
+                    sql.append("BIGINT");
+                } else {
+                    sql.append("INT");
+                }
+                if (!isUseSequenceTable())
                     sql.append(" GENERATED ALWAYS AS IDENTITY");
                 break;
-            }    
+            }
             case TEXT:
             { // Check fixed or variable length
                 int size = Math.abs((int) c.getSize());
@@ -553,9 +562,10 @@ public class DBDatabaseDriverDerby exten
                 sql.append("TIMESTAMP");
                 break;
             case BOOL:
-            	if ( booleanType==BooleanType.CHAR )
-                    sql.append("CHAR(1)");
-                else sql.append("SMALLINT");
+//            	if ( booleanType== DBDatabaseDriverOracle.BooleanType.CHAR ) <- this looks
weird to me :), i commented it out since it is always false for derby
+//                    sql.append("CHAR(1)");
+//                else
+                sql.append("SMALLINT");
                 break;
             case DOUBLE:
                 sql.append("DOUBLE");

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=1061999&r1=1061998&r2=1061999&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
Fri Jan 21 20:07:36 2011
@@ -18,11 +18,6 @@
  */
 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.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.empire.commons.Errors;
@@ -44,6 +39,11 @@ import org.apache.empire.db.DBTable;
 import org.apache.empire.db.DBTableColumn;
 import org.apache.empire.db.DBView;
 
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+
 
 /**
  * This class provides support for the PostgreSQL database system.
@@ -657,24 +657,33 @@ public class DBDatabaseDriverPostgreSQL 
         {
             case INTEGER:
             { // Integer type
-                sql.append("INT");
-                int size = (int)c.getSize();
-                if (size>0)
-                {   // Set Integer length
-                    sql.append("(");
-                    sql.append(String.valueOf(size));
-                    sql.append(")");
+                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
-                sql.append("INT");
-                
-                //String seqName = createSequenceName(c);                
+                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());
@@ -730,7 +739,7 @@ public class DBDatabaseDriverPostgreSQL 
                 sql.append("CHAR(36)");
                 break;
             case UNKNOWN:
-                 log.error("Cannot append column of Data-Type 'UNKNOWN'");
+                 //log.error("Cannot append column of Data-Type 'UNKNOWN'");
                  return false;
         }
         // Default Value



Mime
View raw message