db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1063656 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/CrossConverters.java engine/org/apache/derby/iapi/types/SQLChar.java
Date Wed, 26 Jan 2011 09:32:36 GMT
Author: kahatlen
Date: Wed Jan 26 09:32:35 2011
New Revision: 1063656

URL: http://svn.apache.org/viewvc?rev=1063656&view=rev
Log:
DERBY-4965: Boolean to char conversion results in integer

- Remove reference to non-existent document and improve comments

- Reduce number of calls to String.trim() in getBooleanFromString()

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/CrossConverters.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/CrossConverters.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/CrossConverters.java?rev=1063656&r1=1063655&r2=1063656&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/CrossConverters.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/CrossConverters.java Wed Jan
26 09:32:35 2011
@@ -971,9 +971,26 @@ final class CrossConverters {
         return source.intValue() != 0;
     }
 
-    // See differences.html for DNC getBoolean() semantics.
-    final boolean getBooleanFromString(String source) throws SqlException {
-        return !(source.trim().equals("0") || source.trim().equals("false"));
+    /**
+     * <p>
+     * Get a boolean value from a CHAR column. In order to match the embedded
+     * driver and JCC we return false iff the CHAR value is "0" or "false".
+     * </p>
+     *
+     * <p>
+     * Leading and trailing whitespace is removed from the input string before
+     * it's compared to "0" and "false". No other normalization is performed.
+     * Specifically, no case conversion is performed, so the comparison is
+     * case sensitive, and everything that doesn't exactly match "0" or "false"
+     * will be considered true.
+     * </p>
+     *
+     * @param source the value of a CHAR column
+     * @return false if source is "0" or "false", true otherwise
+     */
+    final boolean getBooleanFromString(String source) {
+        String trimmed = source.trim();
+        return !(trimmed.equals("0") || trimmed.equals("false"));
     }
 
     //---------------------------- getByte*() methods ----------------------------

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java?rev=1063656&r1=1063655&r2=1063656&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLChar.java Wed Jan 26 09:32:35
2011
@@ -250,7 +250,7 @@ public class SQLChar
      * Return false for only "0" or "false" for false. No case insensitivity. 
      * Everything else is true.
      * <p>
-     * The above matches JCC.
+     * The above matches JCC and the client driver.
      *
      *
      * @see DataValueDescriptor#getBoolean
@@ -263,8 +263,8 @@ public class SQLChar
         if (isNull()) 
             return false;
 
-        // match JCC, match only "0" or "false" for false. No case 
-        // insensitivity. everything else is true.
+        // Match JCC and the client driver. Match only "0" or "false" for
+        // false. No case insensitivity. Everything else is true.
 
         String cleanedValue = getString().trim();
 



Mime
View raw message