db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1032780 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Mon, 08 Nov 2010 23:02:21 GMT
Author: rhillegas
Date: Mon Nov  8 23:02:21 2010
New Revision: 1032780

URL: http://svn.apache.org/viewvc?rev=1032780&view=rev
Log:
DERBY-4890: Add BOOLEAN to the list of types supported by the setString() methods.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java?rev=1032780&r1=1032779&r2=1032780&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java Mon
Nov  8 23:02:21 2010
@@ -2823,6 +2823,7 @@ public class PreparedStatement extends S
                 java.sql.Types.REAL,
                 java.sql.Types.DOUBLE,
                 java.sql.Types.VARCHAR,
+                java.sql.Types.BOOLEAN,
                 java.sql.Types.DATE,
                 java.sql.Types.TIME,
                 java.sql.Types.TIMESTAMP,

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java?rev=1032780&r1=1032779&r2=1032780&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ParameterMappingTest.java
Mon Nov  8 23:02:21 2010
@@ -1633,12 +1633,6 @@ public class ParameterMappingTest extend
         String msg;
         boolean shouldWork = B2_MOD[whichCall][type];
 
-        if (usingDerbyNetClient() && (whichCall == 8 /* getString */)
-                && (jdbcTypes[type] == Types.BOOLEAN)) {
-            // Workaround for DERBY-4890.
-            shouldWork = false;
-        }
-
         if (worked && shouldWork)
             msg = " JDBC MATCH(OK)";
         else if (worked)
@@ -1663,12 +1657,6 @@ public class ParameterMappingTest extend
         String msg;
         boolean shouldWork = B5[b5o][type];
 
-        if (usingDerbyNetClient() && (b5o == 0 /* java.lang.String */)
-                && (jdbcTypes[type] == Types.BOOLEAN)) {
-            // Workaround for DERBY-4890.
-            shouldWork = false;
-        }
-
         if (worked && shouldWork)
             msg = " JDBC MATCH(OK)";
         else if (worked)

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=1032780&r1=1032779&r2=1032780&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
Mon Nov  8 23:02:21 2010
@@ -423,6 +423,23 @@ public class BooleanValuesTest  extends 
                  ")\n"
                  );
         }
+        
+        if ( !tableExists( conn, "T_4889" ) )
+        {
+            //
+            // create table
+            //
+            goodStatement
+                (
+                 conn,
+                 "create table t_4889\n" +
+                 "(\n" +
+                 "    key_col int,\n" +
+                 "    setter_col varchar( 20 ),\n" +
+                 "    boolean_col  boolean\n" +
+                 ")\n"
+                 );
+        }
     }
 
 
@@ -1506,6 +1523,137 @@ public class BooleanValuesTest  extends 
         goodStatement( conn, "drop table livenessChange" );
     }
     
+    /**
+     * <p>
+     * Verify fix for DERBY-4890.
+     * </p>
+     */
+    public void test_4890() throws Exception
+    {
+        Connection conn = getConnection();
+
+        goodStatement( conn, "delete from boolean_table" );
+
+        PreparedStatement ps = chattyPrepare( conn, "values ( cast ( ? as boolean ), cast
( ? as boolean ) )" );
+        ps.setString( 1, "true" );
+        ps.setString( 2, "false" );
+        ResultSet rs = ps.executeQuery();
+
+        rs.next();
+        assertTrue( rs.getBoolean( 1 ) );
+        assertFalse( rs.getBoolean( 2 ) );
+
+        rs.close();
+        ps.close();
+
+        ps = chattyPrepare
+            (
+             conn,
+             "insert into boolean_table( key_col, boolean_col ) values ( 1, ? ), ( 2, ? )"
+             );
+        ps.setString( 1, "true" );
+        ps.setString( 2, "false" );
+        ps.execute();
+
+        assertResults
+            (
+             conn,
+             "select * from boolean_table order by key_col",
+             new String[][]
+             {
+                 { "1",  "true" },
+                 { "2",  "false" },
+             },
+             false
+             );
+
+        goodStatement( conn, "delete from boolean_table" );
+    }
+    
+    /**
+     * <p>
+     * Verify fix for DERBY-4890.
+     * </p>
+     */
+    public void test_4889() throws Exception
+    {
+        Connection conn = getConnection();
+
+        minion_4889( conn, 0, false );
+        minion_4889( conn, 1, true );
+        minion_4889( conn, 2, true );
+    }
+    private void minion_4889( Connection conn, int value, boolean expectedBooleanResult )
+        throws Exception
+    {
+        goodStatement( conn, "delete from t_4889" );
+        
+        PreparedStatement ps = chattyPrepare
+            (
+             conn,
+             "insert into t_4889( key_col, setter_col, boolean_col ) values ( ?, ?, ? )"
+             );
+
+        ps.setInt( 1, 1 );
+        ps.setString( 2, "setByte" );
+        ps.setByte( 3, (byte) value );
+        ps.execute();
+
+        ps.setInt( 1, 2 );
+        ps.setString( 2, "setShort" );
+        ps.setShort( 3, (short) value );
+        ps.execute();
+
+        ps.setInt( 1, 3 );
+        ps.setString( 2, "setInt" );
+        ps.setInt( 3, value );
+        ps.execute();
+
+        ps.setInt( 1, 4 );
+        ps.setString( 2, "setLong" );
+        ps.setLong( 3, (long) value );
+        ps.execute();
+
+        ps.setInt( 1, 5 );
+        ps.setString( 2, "setObject( Byte )" );
+        ps.setObject( 3, new Byte( (byte) value ) );
+        ps.execute();
+
+        ps.setInt( 1, 6 );
+        ps.setString( 2, "setObject( Short )" );
+        ps.setObject( 3, new Short( (short) value ) );
+        ps.execute();
+
+        ps.setInt( 1, 7 );
+        ps.setString( 2, "setObject( Integer )" );
+        ps.setObject( 3, new Integer( value ) );
+        ps.execute();
+
+        ps.setInt( 1, 8 );
+        ps.setString( 2, "setObject( Long )" );
+        ps.setObject( 3, new Long( (long) value ) );
+        ps.execute();
+
+        String stringValue = Boolean.toString( (value != 0) );
+        assertResults
+            (
+             conn,
+             "select * from t_4889 order by key_col",
+             new String[][]
+             {
+                 { "1",  "setByte", stringValue },
+                 { "2",  "setShort", stringValue },
+                 { "3",  "setInt", stringValue },
+                 { "4",  "setLong", stringValue },
+                 { "5",  "setObject( Byte )", stringValue },
+                 { "6",  "setObject( Short )", stringValue },
+                 { "7",  "setObject( Integer )", stringValue },
+                 { "8",  "setObject( Long )", stringValue },
+             },
+             false
+             );
+
+    }
 
     ///////////////////////////////////////////////////////////////////////////////////
     //



Mime
View raw message