db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r498710 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
Date Mon, 22 Jan 2007 17:16:53 GMT
Author: djd
Date: Mon Jan 22 09:16:52 2007
New Revision: 498710

URL: http://svn.apache.org/viewvc?view=rev&rev=498710
Log:
DERBY-2242 (partial) More testing for DatabaseMetaData.getTypeInfo

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java?view=diff&rev=498710&r1=498709&r2=498710
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
Mon Jan 22 09:16:52 2007
@@ -1001,7 +1001,36 @@
             
             // LITERAL_PREFIX (column 4)
             // LITERAL_SUFFIX (column 5)
+            
             // CREATE_PARAMS (column 6)
+            String createParams;
+            switch (type)
+            {
+            case Types.CHAR:
+            case Types.VARCHAR:
+            case Types.BLOB:
+            case Types.CLOB:
+            case Types.BINARY:
+            case Types.VARBINARY:
+                createParams = "length";
+                break;
+                
+            case Types.DECIMAL:
+            case Types.NUMERIC:
+                createParams = "precision,scale";
+                break;
+                
+            case Types.FLOAT:
+                createParams = "precision";
+                break;
+                
+            default:
+                createParams = null;
+                break;
+            }
+            assertEquals("CREATE_PARAMS " + typeName,
+                    createParams, rs.getString("CREATE_PARAMS"));
+                     
             
             // NULLABLE (column 7) - all types are nullable in Derby
             assertEquals("NULLABLE " + typeName,
@@ -1035,7 +1064,6 @@
                 searchable = DatabaseMetaData.typePredBasic;
                 break;  
             }
-
             assertEquals("SEARCHABLE " + typeName,
                     searchable, rs.getInt("SEARCHABLE"));
             }
@@ -1046,15 +1074,68 @@
             
             
             // FIXED_PREC_SCALE (column 11)
+            boolean fixedScale = type == Types.DECIMAL || type == Types.NUMERIC;
+            assertEquals("FIXED_PREC_SCALE " + typeName,
+                    fixedScale, rs.getBoolean("FIXED_PREC_SCALE"));
+            assertFalse(rs.wasNull());
+            
             // AUTO_INCREMENT (column 12)
+            boolean autoIncrement;
+            switch (type)
+            {
+            case Types.BIGINT:
+            case Types.INTEGER:
+            case Types.SMALLINT:
+                autoIncrement = true;
+                break;
+            default:
+                autoIncrement = false;
+                break;
+            }
+            assertEquals("AUTO_INCREMENT " + typeName,
+                    autoIncrement, rs.getBoolean("AUTO_INCREMENT"));
             
             // LOCAL_TYPE_NAME (column 13) always the same as TYPE_NAME
             assertEquals("LOCAL_TYPE_NAME " + typeName,
                     typeName, rs.getString("LOCAL_TYPE_NAME"));
             
             
+            int maxScale;
+            boolean hasScale = true;
+            switch (type)
+            {
+            case Types.DECIMAL:
+            case Types.NUMERIC:
+                maxScale = 32767; // 31; BUG DERBY-2262
+                break;
+            case Types.TIMESTAMP:
+                maxScale = 6;
+                break;
+            case Types.SMALLINT:
+            case Types.INTEGER:
+            case Types.BIGINT:
+            case Types.DATE:
+            case Types.TIME:
+                maxScale = 0;
+                break;
+            default:
+                maxScale = 0;
+                hasScale = false;
+                break;
+            }
+            
             // MINIMUM_SCALE (column 14)
+            assertEquals("MINIMUM_SCALE " + typeName,
+                    0, rs.getInt("MINIMUM_SCALE"));
+            assertEquals("MINIMUM_SCALE (wasNull) " + typeName,
+                    !hasScale, rs.wasNull());
+            
             // MAXIMUM_SCALE (column 15)
+            assertEquals("MAXIMUM_SCALE " + typeName,
+                    maxScale, rs.getInt("MAXIMUM_SCALE"));            
+            assertEquals("MAXIMUM_SCALE (wasNull)" + typeName,
+                    !hasScale, rs.wasNull());
+
             
             // SQL_DATA_TYPE (column 16) - Unused
             assertEquals("SQL_DATA_TYPE " + typeName,



Mime
View raw message