Skip to content

Commit

Permalink
Merge pull request #267 from sgaertner/JoinClause_patch
Browse files Browse the repository at this point in the history
bug fix for expressions with more than 9 join clauses causing SQL errors
  • Loading branch information
darkv committed Aug 21, 2012
2 parents 929fc11 + 5200962 commit 23cc1bb
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -920,24 +920,36 @@ 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;
}
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;
}
}

Expand Down

0 comments on commit 23cc1bb

Please sign in to comment.