From adb506cf387e5ce857f18c5a725f5f93c445b239 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sun, 29 Oct 2006 22:56:35 +0000 Subject: Inner join syntax compatible with more SQL parsers. --- .../com/amazon/carbonado/repo/jdbc/JDBCStorage.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java index b06bf99..a1d4cd9 100644 --- a/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java +++ b/src/main/java/com/amazon/carbonado/repo/jdbc/JDBCStorage.java @@ -720,13 +720,24 @@ class JDBCStorage extends StandardQueryFactory } /** - * Appends table names, aliases, and joins to the given FROM clause - * builder. + * Appends table name and alias to the given FROM clause builder. */ - public void appendFullJoinTo(StatementBuilder fromClause) { + public void appendTableNameAndAliasTo(StatementBuilder fromClause) { appendTableNameTo(fromClause); fromClause.append(' '); fromClause.append(mAlias); + } + + /** + * Appends table names, aliases, and joins to the given FROM clause + * builder. + */ + public void appendFullJoinTo(StatementBuilder fromClause) { + appendTableNameAndAliasTo(fromClause); + appendTailJoinTo(fromClause); + } + + private void appendTailJoinTo(StatementBuilder fromClause) { for (JoinNode jn : mSubNodes.values()) { // TODO: By default, joins are all inner. A join could become // LEFT OUTER JOIN if the query filter has a term like this: @@ -737,7 +748,7 @@ class JDBCStorage extends StandardQueryFactory // "address(.)state = ?". fromClause.append(" INNER JOIN"); - jn.appendFullJoinTo(fromClause); + jn.appendTableNameAndAliasTo(fromClause); fromClause.append(" ON "); int count = jn.mProperty.getJoinElementCount(); for (int i=0; i extends StandardQueryFactory fromClause.append('.'); fromClause.append(jn.mProperty.getExternalJoinElement(i).getColumnName()); } + + jn.appendTailJoinTo(fromClause); } } -- cgit v1.2.3