You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2010/06/18 11:21:23 UTC

svn commit: r955900 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java

Author: kahatlen
Date: Fri Jun 18 09:21:18 2010
New Revision: 955900

URL: http://svn.apache.org/viewvc?rev=955900&view=rev
Log:
DERBY-4707: Incorrect nullability when casting non-nullable VARCHAR to BOOLEAN

Added test case. Disabled for now.

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java?rev=955900&r1=955899&r2=955900&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java Fri Jun 18 09:21:18 2010
@@ -788,6 +788,29 @@ public class BooleanValuesTest  extends 
         expectCompilationError( BAD_CONVERSION, "select cast( isindex as " + dataType + " ) from sys.sysconglomerates" );
     }
 
+    /**
+     * Regression test case for DERBY-4704. When casting non-nullable VARCHAR
+     * columns to BOOLEAN, the result column was marked as non-nullable, even
+     * though the VARCHAR could contain the value 'UNKNOWN', in which case
+     * the cast should return NULL.
+     *
+     * The test case is disabled for now. Enable it when the bug is fixed.
+     */
+    public void disabled_testNullabilityOfCastFromNonNullableVARCHAR()
+            throws SQLException {
+        setAutoCommit(false); // for automatic rollback when test has completed
+        Statement s = createStatement();
+        s.execute("create table nonnullablestrings(x varchar(10) not null)");
+        s.execute("insert into nonnullablestrings " +
+                  "values 'true', 'false', 'unknown'");
+
+        ResultSet rs = s.executeQuery(
+                "select cast(x as boolean) from nonnullablestrings");
+        JDBC.assertNullability(rs, new boolean[] { true });
+        JDBC.assertFullResultSet(
+                rs, new String[][] { {"true"}, {"false"}, {null} });
+    }
+
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // SQL ROUTINES