db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r955900 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
Date Fri, 18 Jun 2010 09:21:23 GMT
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



Mime
View raw message