db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abr...@apache.org
Subject svn commit: r472391 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java
Date Wed, 08 Nov 2006 04:53:55 GMT
Author: abrown
Date: Tue Nov  7 20:53:54 2006
New Revision: 472391

URL: http://svn.apache.org/viewvc?view=rev&rev=472391
Log:
DERBY-2052: JDBC.assertRowInResultSet compares the wrong value if using
trimmed strings and a SMALLINT column exists. 

Patch that 1) moves the locally scoped variables in JDBC.assertRowInResultSet()
into the for loop, and 2) sets the "obj" variable through all paths.

Contributed by Dan Debrunner (djd@apache.org) 

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java?view=diff&rev=472391&r1=472390&r2=472391
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java Tue Nov  7 20:53:54
2006
@@ -597,12 +597,10 @@
     private static void assertRowInResultSet(ResultSet rs, int rowNum,
         Object [] expectedRow, boolean asTrimmedStrings) throws SQLException
     {
-        String s;
-        boolean ok;
-        Object obj = null;
         ResultSetMetaData rsmd = rs.getMetaData();
         for (int i = 0; i < expectedRow.length; i++)
         {
+            Object obj;
             if (asTrimmedStrings)
             {
                 // Trim the expected value, if non-null.
@@ -621,24 +619,28 @@
                 if ((expectedRow[i] != null)
                     && (rsmd.getColumnType(i+1) == Types.SMALLINT))
                 {
-                    s = expectedRow[i].toString();
+                    String s = expectedRow[i].toString();
                     if (s.equals("true") || s.equals("false"))
                         obj = (rs.getShort(i+1) == 0) ? "false" : "true";
+                    else
+                        obj = rs.getString(i+1);
+                        
                 }
                 else
                 {
                     obj = rs.getString(i+1);
 
-                    // Trim the rs string.
-                    if (obj != null)
-                        obj = ((String)obj).trim();
                 }
+                
+                // Trim the rs string.
+                if (obj != null)
+                    obj = ((String)obj).trim();
 
             }
             else
                 obj = rs.getObject(i+1);
 
-            ok = (rs.wasNull() && (expectedRow[i] == null))
+            boolean ok = (rs.wasNull() && (expectedRow[i] == null))
                 || (!rs.wasNull()
                     && (expectedRow[i] != null)
                     && expectedRow[i].equals(obj));



Mime
View raw message