Skip to content

Commit

Permalink
reworked getInvolvedPlaceHolders method for select objects
Browse files Browse the repository at this point in the history
  • Loading branch information
clausnagel committed Apr 26, 2019
1 parent d78098a commit 04f0fe5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/main/java/org/citydb/sqlbuilder/select/Select.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,24 @@ public List<PlaceHolder<?>> getInvolvedPlaceHolders() {

for (ProjectionToken token : projectionTokens)
token.getInvolvedPlaceHolders(statements);

for (Table table : getInvolvedTables()) {

Set<Table> tables = new LinkedHashSet<>();
for (ProjectionToken token : projectionTokens)
token.getInvolvedTables(tables);

for (Table table : tables) {
if (table.isSetQueryExpression())
table.getQueryExpression().getInvolvedPlaceHolders(statements);
}

for (Join join : joins) {
Table table = join.getToColumn().getTable();
if (table.isSetQueryExpression() && !tables.contains(table))
table.getQueryExpression().getInvolvedPlaceHolders(statements);

join.getInvolvedPlaceHolders(statements);
}

for (PredicateToken token : predicateTokens)
token.getInvolvedPlaceHolders(statements);

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/org/citydb/sqlbuilder/select/join/Join.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.citydb.sqlbuilder.select.join;

import org.citydb.sqlbuilder.expression.PlaceHolder;
import org.citydb.sqlbuilder.schema.Column;
import org.citydb.sqlbuilder.schema.Table;
import org.citydb.sqlbuilder.select.PredicateToken;
Expand Down Expand Up @@ -84,9 +85,14 @@ public void getInvolvedTables(Set<Table> tables) {
fromColumn.getInvolvedTables(tables);
toColumn.getInvolvedTables(tables);
}

public void getInvolvedPlaceHolders(List<PlaceHolder<?>> statements) {
for (PredicateToken condition : conditions)
condition.getInvolvedPlaceHolders(statements);
}

@Override
public String toString() {
public String toString() {
return name + " " + toColumn.getTable() + " on " + new BinaryLogicalOperator(conditionOperationName, conditions);
}

Expand Down

0 comments on commit 04f0fe5

Please sign in to comment.