Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 66939 invoked from network); 4 Oct 2010 11:11:35 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 4 Oct 2010 11:11:35 -0000 Received: (qmail 45955 invoked by uid 500); 4 Oct 2010 11:11:34 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 45884 invoked by uid 500); 4 Oct 2010 11:11:32 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 45876 invoked by uid 99); 4 Oct 2010 11:11:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Oct 2010 11:11:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Oct 2010 11:11:28 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A925623889E3; Mon, 4 Oct 2010 11:11:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1004197 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/load/ColumnInfo.java testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java Date: Mon, 04 Oct 2010 11:11:07 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101004111107.A925623889E3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kahatlen Date: Mon Oct 4 11:11:07 2010 New Revision: 1004197 URL: http://svn.apache.org/viewvc?rev=1004197&view=rev Log: DERBY-4828: Import fails if column names contain double quotes Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java?rev=1004197&r1=1004196&r2=1004197&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/load/ColumnInfo.java Mon Oct 4 11:11:07 2010 @@ -387,11 +387,11 @@ class ColumnInfo { sb.append(", "); else first = false; - // column names can be SQL reserved words, so it - // is necessary delimit them using quotes for insert to work correctly. - sb.append("\""); - sb.append(insertColumnNames.get(index)); - sb.append("\""); + // Column names can be SQL reserved words, or they can contain + // spaces and special characters, so it is necessary delimit them + // for insert to work correctly. + String name = (String) insertColumnNames.get(index); + sb.append(IdUtil.normalToDelimited(name)); } //there is no column info available Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java?rev=1004197&r1=1004196&r2=1004197&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ImportExportTest.java Mon Oct 4 11:11:07 2010 @@ -241,6 +241,44 @@ public class ImportExportTest extends Ba } /** + * Test that we can successfully export from and import to tables that + * have columns with special characters in their names (single and double + * quotes, spaces, mixed case). Regression test case for DERBY-4828. + */ + public void testQuotesInColumnNames() throws Exception { + Statement s = createStatement(); + + // Create a source table with column names that contain special + // characters. + s.execute("create table table_with_funny_cols_src (" + // simple column name + + "x int, " + // column name with single and double quotes, mixed case + // and spaces + + "\"Let's try this! \"\" :)\" int)"); + s.execute("insert into table_with_funny_cols_src values (1,2), (3,4)"); + + // Export the table to a file. + doExport(null, "TABLE_WITH_FUNNY_COLS_SRC", null, null, null); + + // Create an empty destination table with the same schema as the + // source table. + s.execute("create table table_with_funny_cols_dest as " + + "select * from table_with_funny_cols_src with no data"); + + // Import into the destination table. + doImport("TABLE_WITH_FUNNY_COLS_SRC", + null, "TABLE_WITH_FUNNY_COLS_DEST", + null, null, null, 0); + + // Verify that the rows were successfully imported. + JDBC.assertFullResultSet( + s.executeQuery( + "select * from table_with_funny_cols_dest order by x"), + new String[][] { {"1", "2"}, {"3", "4"} }); + } + + /** * Test that you can't import the wrong type of object into a UDT column. */ public void testCastingProblem() throws Exception