From 520096249d63629a6c147da8869cd5f175454a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Ga=CC=88rtner?= Date: Tue, 21 Aug 2012 12:39:09 +0200 Subject: [PATCH] bug fix for expressions with more than 9 join clauses causing SQL errors --- .../jdbcadaptor/PostgresqlExpression.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Frameworks/PlugIns/PostgresqlPlugIn/Sources/com/webobjects/jdbcadaptor/PostgresqlExpression.java b/Frameworks/PlugIns/PostgresqlPlugIn/Sources/com/webobjects/jdbcadaptor/PostgresqlExpression.java index afad8ecaff4..0f1e9fc2b3a 100644 --- a/Frameworks/PlugIns/PostgresqlPlugIn/Sources/com/webobjects/jdbcadaptor/PostgresqlExpression.java +++ b/Frameworks/PlugIns/PostgresqlPlugIn/Sources/com/webobjects/jdbcadaptor/PostgresqlExpression.java @@ -249,7 +249,7 @@ public String assembleJoinClause(String leftName, } JoinClause jc = new JoinClause(); - jc.table1 = leftTable + " " + leftAlias; + jc.setTable1(leftTable, leftAlias); switch (semantic) { case EORelationship.LeftOuterJoin: @@ -920,11 +920,14 @@ public class JoinClause { String op; String table2; String joinCondition; + String sortKey; + @Override public String toString() { return table1 + op + table2 + joinCondition; } + @Override public boolean equals( Object obj ) { if( obj == null || !(obj instanceof JoinClause) ) { return false; @@ -932,12 +935,21 @@ public boolean equals( Object obj ) { return toString().equals( obj.toString() ); } + public void setTable1(String leftTable, String leftAlias) { + table1 = leftTable + " " + leftAlias; + sortKey = leftAlias.substring(1); + if (sortKey.length() < 2) { + // add padding for cases with >9 joins + sortKey = " " + sortKey; + } + } + /** * Property that makes this class "sortable". * Needed to correctly assemble a join clause. */ public String sortKey() { - return table1.substring( table1.indexOf( " " ) + 1 ); + return sortKey; } }