diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2016-01-12 22:41:43 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2016-01-12 22:41:43 +0000 |
commit | 69b84ac737d53c00bf801eccca774535b0a9610c (patch) | |
tree | 8af6e5b4d8258e8b53896a1c81f5f77599a39c0c /src/test/java/com/healthmarketscience/jackcess/query | |
parent | fb33e1e13f201d8993833a6e7a843483df5c5d7e (diff) | |
download | jackcess-69b84ac737d53c00bf801eccca774535b0a9610c.tar.gz jackcess-69b84ac737d53c00bf801eccca774535b0a9610c.zip |
Fix missing column names in AppendQuery SQL strings. Fixes #131
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@977 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/test/java/com/healthmarketscience/jackcess/query')
-rw-r--r-- | src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java b/src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java index 3af50ec..b9a284c 100644 --- a/src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java @@ -206,7 +206,7 @@ public class QueryTest extends TestCase "WHERE (((Table1.col1)>\"blah\"));")); expectedQueries.put( "AppendQuery",multiline( - "INSERT INTO Table3", + "INSERT INTO Table3 (col2, col2, col3)", "SELECT [Table1].[col2], [Table2].[col2], [Table2].[col3]", "FROM Table3, Table1 INNER JOIN Table2 ON [Table1].[col1]=[Table2].[col1];")); expectedQueries.put( @@ -257,6 +257,27 @@ public class QueryTest extends TestCase } } + public void testAppendQuery() throws Exception + { + AppendQuery query = (AppendQuery)newQuery( + Query.Type.APPEND, null, "Table2", + // newRow(TABLE_ATTRIBUTE, null, "Table1", null), + newRow(COLUMN_ATTRIBUTE, "54", APPEND_VALUE_FLAG, null, null), + newRow(COLUMN_ATTRIBUTE, "'hello'", APPEND_VALUE_FLAG, null, null)); + + assertEquals(multiline("INSERT INTO Table2", + "VALUES (54, 'hello');"), query.toSQLString()); + + query = (AppendQuery)newQuery( + Query.Type.APPEND, null, "Table2", + // newRow(TABLE_ATTRIBUTE, null, "Table1", null), + newRow(COLUMN_ATTRIBUTE, "54", APPEND_VALUE_FLAG, null, "ID"), + newRow(COLUMN_ATTRIBUTE, "'hello'", APPEND_VALUE_FLAG, null, "Field 3")); + + assertEquals(multiline("INSERT INTO Table2 (ID, [Field 3])", + "VALUES (54, 'hello');"), query.toSQLString()); + } + private void doTestColumns(SelectQuery query) throws Exception { addRows(query, newRow(COLUMN_ATTRIBUTE, "Table1.id", null, null)); |