From 04f0fe5dac5334be7c72d8e5fb61694ffb8ecaf6 Mon Sep 17 00:00:00 2001 From: Claus Nagel Date: Fri, 26 Apr 2019 15:10:41 +0200 Subject: [PATCH] reworked getInvolvedPlaceHolders method for select objects --- .../org/citydb/sqlbuilder/select/Select.java | 16 ++++++++++++++-- .../org/citydb/sqlbuilder/select/join/Join.java | 8 +++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/citydb/sqlbuilder/select/Select.java b/src/main/java/org/citydb/sqlbuilder/select/Select.java index f2c93e2..7bf3a71 100644 --- a/src/main/java/org/citydb/sqlbuilder/select/Select.java +++ b/src/main/java/org/citydb/sqlbuilder/select/Select.java @@ -299,12 +299,24 @@ public List> getInvolvedPlaceHolders() { for (ProjectionToken token : projectionTokens) token.getInvolvedPlaceHolders(statements); - - for (Table table : getInvolvedTables()) { + + Set 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); diff --git a/src/main/java/org/citydb/sqlbuilder/select/join/Join.java b/src/main/java/org/citydb/sqlbuilder/select/join/Join.java index dcc0e04..8473f3d 100644 --- a/src/main/java/org/citydb/sqlbuilder/select/join/Join.java +++ b/src/main/java/org/citydb/sqlbuilder/select/join/Join.java @@ -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; @@ -84,9 +85,14 @@ public void getInvolvedTables(Set
tables) { fromColumn.getInvolvedTables(tables); toColumn.getInvolvedTables(tables); } + + public void getInvolvedPlaceHolders(List> statements) { + for (PredicateToken condition : conditions) + condition.getInvolvedPlaceHolders(statements); + } @Override - public String toString() { + public String toString() { return name + " " + toColumn.getTable() + " on " + new BinaryLogicalOperator(conditionOperationName, conditions); }