db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1074127 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/PreparedStatement.java client/org/apache/derby/client/net/NetStatementRequest.java testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
Date Thu, 24 Feb 2011 12:53:50 GMT
Author: kahatlen
Date: Thu Feb 24 12:53:50 2011
New Revision: 1074127

URL: http://svn.apache.org/viewvc?rev=1074127&view=rev
Log:
DERBY-5042: ResultSet.updateBoolean() on new BOOLEAN type throws exception

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.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=1074127&r1=1074126&r2=1074127&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 Thu
Feb 24 12:53:50 2011
@@ -497,7 +497,7 @@ public class PreparedStatement extends S
                 }
                 
                 parameterMetaData_.clientParamtertype_[parameterIndex - 1] = java.sql.Types.BIT;
-                setInput(parameterIndex, new Short((short) (x ? 1 : 0)));
+                setInput(parameterIndex, Boolean.valueOf(x));
             }
         }
         catch ( SqlException se )

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java?rev=1074127&r1=1074126&r2=1074127&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementRequest.java Thu
Feb 24 12:53:50 2011
@@ -722,7 +722,7 @@ public class NetStatementRequest extends
                         break;
 
                     case DRDAConstants.DRDA_TYPE_NBOOLEAN:
-                        write1Byte(((Short) inputs[i]).shortValue());
+                        writeBoolean(((Boolean) inputs[i]).booleanValue());
                         break;
                     case DRDAConstants.DRDA_TYPE_NINTEGER:
                         writeIntFdocaData(((Integer) inputs[i]).intValue());

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=1074127&r1=1074126&r2=1074127&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
Thu Feb 24 12:53:50 2011
@@ -1820,6 +1820,42 @@ public class BooleanValuesTest  extends 
     }
 
     /**
+     * Verify fix for DERBY-5042, where updateBoolean() and updateObject()
+     * would fail on a BOOLEAN column when using the client driver.
+     */
+    public void test_5042_updateBoolean() throws SQLException {
+        setAutoCommit(false);
+
+        Statement s = createStatement(ResultSet.TYPE_FORWARD_ONLY,
+                                      ResultSet.CONCUR_UPDATABLE);
+        s.execute("create table derby5042(b boolean, i int, c char(10))");
+
+        ResultSet rs = s.executeQuery("select * from derby5042");
+
+        // Test updateBoolean() on various column types
+        rs.moveToInsertRow();
+        rs.updateBoolean("B", true); // Used to fail with client driver
+        rs.updateBoolean("I", true);
+        rs.updateBoolean("C", true);
+        rs.insertRow();
+
+        // Test updateObject() with a java.lang.Boolean on various column types
+        rs.moveToInsertRow();
+        rs.updateObject("B", Boolean.FALSE); // Used to fail with client driver
+        rs.updateObject("I", Boolean.FALSE);
+        rs.updateObject("C", Boolean.FALSE);
+        rs.insertRow();
+
+        rs.close();
+
+        JDBC.assertFullResultSet(
+                s.executeQuery("select * from derby5042 order by 1,2,3"),
+                new String[][]{
+                    {"false", "0", "false"},
+                    {"true", "1", "true"}});
+    }
+
+    /**
      * Verify fix for DERBY-5063 - updateBytes() should fail when invoked
      * on boolean columns.
      */



Mime
View raw message