db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r955940 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/CastNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
Date Fri, 18 Jun 2010 11:21:23 GMT
Author: kahatlen
Date: Fri Jun 18 11:21:23 2010
New Revision: 955940

URL: http://svn.apache.org/viewvc?rev=955940&view=rev
Log:
DERBY-4658: Allow explicit casts of string values to BOOLEAN

Removed unnecessary call to setNullability() and added a test that
verified that the correct nullability had been set.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java?rev=955940&r1=955939&r2=955940&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CastNode.java Fri Jun
18 11:21:23 2010
@@ -464,14 +464,10 @@ public class CastNode extends ValueNode
 				}
 				else if (cleanCharValue.equals("UNKNOWN"))
 				{
-					ConstantNode cn = (ConstantNode) getNodeFactory().getNode(
+					return (ValueNode) getNodeFactory().getNode(
 											C_NodeTypes.BOOLEAN_CONSTANT_NODE,
 											null,
 											getContextManager());
-
-                    cn.setNullability( true );
-
-                    return cn;
 				}
 				else
 				{

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=955940&r1=955939&r2=955940&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 11:21:23 2010
@@ -811,6 +811,38 @@ public class BooleanValuesTest  extends 
                 rs, new String[][] { {"true"}, {"false"}, {null} });
     }
 
+    public void test_10_nullabilityOfCastFromLiteral() throws SQLException {
+        Statement s = createStatement();
+
+        ResultSet rs = s.executeQuery("values cast('true' as boolean)");
+        JDBC.assertNullability(rs, new boolean[] { false });
+        JDBC.assertSingleValueResultSet(rs, "true");
+
+        rs = s.executeQuery("values cast('false' as boolean)");
+        JDBC.assertNullability(rs, new boolean[] { false });
+        JDBC.assertSingleValueResultSet(rs, "false");
+
+        rs = s.executeQuery("values cast('unknown' as boolean)");
+        JDBC.assertNullability(rs, new boolean[] { true });
+        JDBC.assertSingleValueResultSet(rs, null);
+
+        rs = s.executeQuery(
+                "values (cast('true' as boolean),\n" +
+                "        cast('false' as boolean),\n" +
+                "        cast('unknown' as boolean))");
+        JDBC.assertNullability(rs, new boolean[] { false, false, true });
+        JDBC.assertFullResultSet(
+                rs, new String[][] {{ "true", "false", null }});
+
+        rs = s.executeQuery(
+                "values (cast ('true' as boolean)),\n" +
+                "       (cast ('false' as boolean)),\n" +
+                "       (cast ('unknown' as boolean))");
+        JDBC.assertNullability(rs, new boolean[] { true });
+        JDBC.assertFullResultSet(
+                rs, new String[][] { {"true"}, {"false"}, {null} });
+    }
+
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // SQL ROUTINES



Mime
View raw message