db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1566625 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
Date Mon, 10 Feb 2014 13:51:11 GMT
Author: rhillegas
Date: Mon Feb 10 13:51:11 2014
New Revision: 1566625

URL: http://svn.apache.org/r1566625
Log:
DERBY-3155: Add test to verify use of identifiers on the left side of SET clauses in MERGE
statements; commit derby-3155-22-ad-testIdentifiersOnLeftSideOfSetClauses.diff.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java?rev=1566625&r1=1566624&r2=1566625&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
Mon Feb 10 13:51:11 2014
@@ -5035,6 +5035,101 @@ public class MergeStatementTest extends 
         goodStatement( dboConnection, "drop table t1_034" );
     }
     
+    /**
+     * <p>
+     * Verify that table identifiers can be used or omitted on the left
+     * side of SET clauses.
+     * </p>
+     */
+    public  void    test_035_leftSideOfSet()
+        throws Exception
+    {
+        Connection  dboConnection = openUserConnection( TEST_DBO );
+
+        //
+        // create schema
+        //
+        goodStatement
+            (
+             dboConnection,
+             "create table t1_035( x int, y int )"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create table t2_035( x int, y int )"
+             );
+
+        // verify with and without aliases and with and without identifiers on the left side
of SET clauses
+        vet_035
+            (
+             dboConnection,
+             "merge into t1_035\n" +
+             "using t2_035 on t1_035.x = t2_035.x\n" +
+             "when matched then update set t1_035.y = t2_035.y\n"
+             );
+        vet_035
+            (
+             dboConnection,
+             "merge into t1_035\n" +
+             "using t2_035 on t1_035.x = t2_035.x\n" +
+             "when matched then update set y = t2_035.y\n"
+             );
+        vet_035
+            (
+             dboConnection,
+             "merge into t1_035 a\n" +
+             "using t2_035 on a.x = t2_035.x\n" +
+             "when matched then update set a.y = t2_035.y\n"
+             );
+        vet_035
+            (
+             dboConnection,
+             "merge into t1_035 a\n" +
+             "using t2_035 on a.x = t2_035.x\n" +
+             "when matched then update set y = t2_035.y\n" 
+             );
+
+        //
+        // drop schema
+        //
+        goodStatement( dboConnection, "drop table t2_035" );
+        goodStatement( dboConnection, "drop table t1_035" );
+    }
+    private void    vet_035( Connection conn, String query )
+        throws Exception
+    {
+        goodStatement
+            (
+             conn,
+             "delete from t1_035"
+             );
+        goodStatement
+            (
+             conn,
+             "delete from t2_035"
+             );
+        goodStatement
+            (
+             conn,
+             "insert into t1_035 values ( 1, 100 ), ( 2, 200 ), ( 3, 300 )"
+             );
+        goodStatement
+            (
+             conn,
+             "insert into t2_035 values ( 1, 1000 ), ( 3, 3000 ), ( 4, 4000 )"
+             );
+
+        String[][]  expectedResults = new String[][]
+            {
+                { "1", "1000" },
+                { "2", "200" },
+                { "3", "3000" },
+            };
+        goodUpdate( conn, query, 2 );
+        assertResults( conn, "select * from t1_035 order by x", expectedResults, false );
+    }
+    
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // ROUTINES



Mime
View raw message