db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r958610 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/types/SQLBoolean.java testing/org/apache/derbyTesting/functionTests/tests/lang/BooleanValuesTest.java
Date Mon, 28 Jun 2010 15:47:00 GMT
Author: rhillegas
Date: Mon Jun 28 15:47:00 2010
New Revision: 958610

URL: http://svn.apache.org/viewvc?rev=958610&view=rev
Log:
DERBY-4716: Correct sort order for indexed BOOLEANs.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.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/iapi/types/SQLBoolean.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java?rev=958610&r1=958609&r2=958610&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBoolean.java Mon Jun 28
15:47:00 2010
@@ -272,8 +272,8 @@ public final class SQLBoolean
 		/*
 		 * thisNull otherNull thisValue thatValue return
 		 *	T		T			X		X			0	(this == other)
-		 *	F		T			X		X			1 	(this > other)
-		 *	T		F			X		X			-1	(this < other)
+		 *	F		T			X		X			-1 	(this > other)
+		 *	T		F			X		X			1	(this < other)
 		 *
 		 *	F		F			T		T			0	(this == other)
 		 *	F		F			T		F			1	(this > other)
@@ -283,9 +283,9 @@ public final class SQLBoolean
 		if (thisNull || otherNull)
 		{
 			if (!thisNull)		// otherNull must be true
-				return 1;
-			if (!otherNull)		// thisNull must be true
 				return -1;
+			if (!otherNull)		// thisNull must be true
+				return 1;
 			return 0;
 		}
 

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=958610&r1=958609&r2=958610&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 Jun 28 15:47:00 2010
@@ -1033,6 +1033,49 @@ public class BooleanValuesTest  extends 
         goodStatement( conn, "delete from boolean_table" );
     }
     
+    /**
+     * <p>
+     * Verify that boolean nulls sort at the end with or without an index,
+     * the behavior of other datatypes.
+     * </p>
+     */
+    public void test_13_sortOrder() throws Exception
+    {
+        Connection conn = getConnection();
+
+        goodStatement( conn, "create table booleanUnindexed( a boolean )" );
+        goodStatement( conn, "create table booleanIndexed( a boolean )" );
+        goodStatement( conn, "create index bi on booleanIndexed( a )" );
+
+        goodStatement( conn, "insert into booleanUnindexed( a ) values ( true ), ( null ),
( false )" );
+        goodStatement( conn, "insert into booleanIndexed( a ) values ( true ), ( null ),
( false )" );
+
+        String[][] expectedResults = new String[][]
+        {
+            { "false" },
+            { "true" },
+            { null },
+        };
+        
+        assertResults
+            (
+             conn,
+             "select * from booleanUnindexed order by a",
+             expectedResults,
+             false
+             );
+        assertResults
+            (
+             conn,
+             "select * from booleanIndexed order by a",
+             expectedResults,
+             false
+             );
+        
+        goodStatement( conn, "drop table booleanUnindexed" );
+        goodStatement( conn, "drop table booleanIndexed" );
+    }
+
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // SQL ROUTINES



Mime
View raw message