db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r616873 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CaseExpressionTest.java
Date Wed, 30 Jan 2008 19:57:39 GMT
Author: djd
Date: Wed Jan 30 11:57:38 2008
New Revision: 616873

URL: http://svn.apache.org/viewvc?rev=616873&view=rev
Log:
Add some test cases for nullability of the value from a CASE expression. One of the cases
failed before revision 616853 for DERBY-2775.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CaseExpressionTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CaseExpressionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CaseExpressionTest.java?rev=616873&r1=616872&r2=616873&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CaseExpressionTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CaseExpressionTest.java
Wed Jan 30 11:57:38 2008
@@ -304,13 +304,45 @@
         rs = s.executeQuery("SELECT d from t where d = (SELECT CASE WHEN 1 = 0 THEN CURRENT_DATE
 ELSE NULL END from t)");
         JDBC.assertEmpty(rs);
         
-        // Make sure metadata has correct type
+        // Make sure metadata has correct type for various null handling
         rs = s.executeQuery("SELECT CASE WHEN 1 = 1 THEN NULL  ELSE CURRENT_DATE  END from
t");
         ResultSetMetaData rsmd = rs.getMetaData();
         assertEquals(java.sql.Types.DATE, rsmd.getColumnType(1));
         // should be nullable since it returns NULL #:)
-        assertTrue(rsmd.isNullable(1) == ResultSetMetaData.columnNullable);
-        JDBC.assertSingleValueResultSet(rs, null);        
+        assertEquals(ResultSetMetaData.columnNullable, rsmd.isNullable(1));
+        JDBC.assertSingleValueResultSet(rs, null);    
+        
+        rs = s.executeQuery("SELECT CASE WHEN 1 = 0 THEN CURRENT_DATE ELSE NULL END from
t");
+        rsmd = rs.getMetaData();
+        assertEquals(java.sql.Types.DATE, rsmd.getColumnType(1));
+        // should be nullable since it returns NULL #:)
+        assertEquals(ResultSetMetaData.columnNullable, rsmd.isNullable(1));
+        JDBC.assertSingleValueResultSet(rs, null);  
+        
+        // and with an implicit NULL return.
+        rs = s.executeQuery("SELECT CASE WHEN 1 = 0 THEN CURRENT_DATE END from t");
+        rsmd = rs.getMetaData();
+        assertEquals(java.sql.Types.DATE, rsmd.getColumnType(1));
+        // should be nullable since it returns NULL #:)
+        assertEquals(ResultSetMetaData.columnNullable, rsmd.isNullable(1));
+        JDBC.assertSingleValueResultSet(rs, null);  
+        
+        // and no possible NULL return.
+        
+        rs = s.executeQuery("SELECT CASE WHEN 1 = 0 THEN 6 ELSE 4 END from t");
+        rsmd = rs.getMetaData();
+        assertEquals(java.sql.Types.INTEGER, rsmd.getColumnType(1));
+        // should be nullable since it returns NULL #:)
+        assertEquals(ResultSetMetaData.columnNoNulls, rsmd.isNullable(1));
+        JDBC.assertSingleValueResultSet(rs, "4"); 
+        
+        rs = s.executeQuery("SELECT CASE WHEN 1 = 1 THEN 6 ELSE 4 END from t");
+        rsmd = rs.getMetaData();
+        assertEquals(java.sql.Types.INTEGER, rsmd.getColumnType(1));
+        // should be nullable since it returns NULL #:)
+        assertEquals(ResultSetMetaData.columnNoNulls, rsmd.isNullable(1));
+        JDBC.assertSingleValueResultSet(rs, "6");
+        
     }
     
 }



Mime
View raw message