diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2017-06-26 00:28:32 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2017-06-26 00:28:32 +0000 |
commit | c1eb52f4f69ea9320f67f5f7fc4df1b21467d481 (patch) | |
tree | 3798e1c289a124a420787a3b0612ec477c4df8de | |
parent | c3d229ff33263f70358d45c8361fcf1ab689a5c7 (diff) | |
download | jackcess-c1eb52f4f69ea9320f67f5f7fc4df1b21467d481.tar.gz jackcess-c1eb52f4f69ea9320f67f5f7fc4df1b21467d481.zip |
handle missing table name for join expression
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1105 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r-- | src/main/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java | 7 | ||||
-rw-r--r-- | src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java | 9 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java index a9fd5e6..151fd30 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java @@ -267,7 +267,7 @@ public abstract class QueryImpl implements Query return result; } - private Join getJoinExpr(String table, List<Join> joinExprs) + private static Join getJoinExpr(String table, List<Join> joinExprs) { for(Iterator<Join> iter = joinExprs.iterator(); iter.hasNext(); ) { Join joinExpr = iter.next(); @@ -276,8 +276,9 @@ public abstract class QueryImpl implements Query return joinExpr; } } - throw new IllegalStateException(withErrorContext( - "Cannot find join table " + table)); + // just use the table name as is + return new Join(table, toOptionalQuotedExpr(new StringBuilder(), + table, true).toString()); } private Collection<List<Row>> combineJoins(List<Row> joins) diff --git a/src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java b/src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java index b9a284c..0414b35 100644 --- a/src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/query/QueryTest.java @@ -408,12 +408,9 @@ public class QueryTest extends TestCase addRows(query, newRow(JOIN_ATTRIBUTE, "(Table1.id = Table3Val.id)", 1, "BogusTable", "Table3Val")); - try { - query.toSQLString(); - fail("IllegalStateException should have been thrown"); - } catch(IllegalStateException e) { - // success - } + assertEquals(multiline("SELECT Table1.id, Table1.col AS [Some.Alias]", + "FROM BogusTable INNER JOIN ((Table1 INNER JOIN Table2 AS [Another Table] ON (Table1.id = [Another Table].id)) LEFT JOIN [Select val from Table3].val AS Table3Val ON (Table1.id = Table3Val.id)) ON (Table1.id = Table3Val.id);"), + query.toSQLString()); removeRows(query, JOIN_ATTRIBUTE); } |