From c1eb52f4f69ea9320f67f5f7fc4df1b21467d481 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Mon, 26 Jun 2017 00:28:32 +0000 Subject: 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 --- .../com/healthmarketscience/jackcess/impl/query/QueryImpl.java | 7 ++++--- .../java/com/healthmarketscience/jackcess/query/QueryTest.java | 9 +++------ 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src') 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 joinExprs) + private static Join getJoinExpr(String table, List joinExprs) { for(Iterator 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> combineJoins(List 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); } -- cgit v1.2.3