You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2006/08/26 05:55:42 UTC

svn commit: r437070 [2/2] - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/sql/compile/ engine/org/apache/derby/impl/sql/compile/ engine/org/apache/derby/loc/ shared/org/apache/derby/shared/common/reference/ testing/org/apache/derbyTesting/...

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByExpressionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/groupBy.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/groupBy.sql?rev=437070&r1=437069&r2=437070&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/groupBy.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/groupBy.sql Fri Aug 25 20:55:39 2006
@@ -5,7 +5,8 @@
 create table t2 (a int, b int, c int);
 insert into t2 values (1,1,1), (2,2,2);
 
--- group by position
+-- group by constant. should compile but fail because
+-- it is not a valid grouping expression.
 select * from t1 group by 1;
 
 -- column in group by list not in from list
@@ -15,10 +16,6 @@
 select a as b from t1 group by b;
 select a from t1 group by b;
 select a, char(b) from t1 group by a;
-
--- columns in group by list must be unique
-select a, b from t1 group by a, a;
-select a, b from t1 group by a, t1.a;
 
 -- cursor with group by is not updatable
 get cursor c1 as 'select a from t1 group by a for update';

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java?rev=437070&r1=437069&r2=437070&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java Fri Aug 25 20:55:39 2006
@@ -28,6 +28,8 @@
 import java.io.UnsupportedEncodingException;
 import java.sql.*;
 
+import junit.framework.AssertionFailedError;
+
 import org.apache.derby.tools.ij;
 
 
@@ -358,7 +360,6 @@
 
     /**
      * Assert that SQLState is as expected.
-     * The expected SQLState is truncated to five characters if required.
      *
      * @param message message to print on failure.
      * @param expected the expected SQLState.
@@ -372,22 +373,29 @@
         assertNotNull("Exception cannot be null when asserting on SQLState", 
                       exception);
         
-        String state = exception.getSQLState();
-        
-        if ( state != null )
-            assertTrue("The exception's SQL state must be five characters long",
-                exception.getSQLState().length() == 5);
-        
-        if ( expected != null )
-            assertTrue("The expected SQL state must be five characters long",
-                expected.length() == 5);
-        
-        assertEquals(message, expected, state);
+        try {
+            String state = exception.getSQLState();
+            
+            if ( state != null )
+                assertTrue("The exception's SQL state must be five characters long",
+                        state.length() == 5);
+            
+            if ( expected != null )
+                assertTrue("The expected SQL state must be five characters long",
+                    expected.length() == 5);
+            
+            assertEquals(message, expected, state);
+        } catch (AssertionFailedError e) {
+            
+            // Save the SQLException
+            // e.initCause(exception);
+
+            throw e;
+        }
     }
 
     /**
      * Assert that SQLState is as expected.
-     * The expected SQLState is truncated to five characters if required.
      *
      * @param expected the expected SQLState.
      * @param exception the exception to check the SQLState of.
@@ -395,5 +403,23 @@
     public static void assertSQLState(String expected, SQLException exception) {
         assertSQLState("Unexpected SQL state.", expected, exception);
     }
+    /**
+     * Assert that the query does not compile and throws
+     * a SQLException with the expected state.
+     * 
+     * @param sqlstate expected sql state.
+     * @param query the query to compile.
+     */
+    public void assertCompileError(String sqlState, String query) {
+
+        try {
+            prepareStatement(query).close();
+            fail("expected compile error: " + sqlState);
+        } catch (SQLException se) {
+            assertSQLState(sqlState, se);
+        }
+    }
 
 } // End class BaseJDBCTestCase
+
+