Skip to content

Commit

Permalink
Extract join condition formatting to separate method
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo authored and hashhar committed Feb 25, 2022
1 parent 0ba6114 commit 0956887
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,7 @@ public PreparedQuery prepareJoinQuery(
formatJoinType(joinType),
rightSource.getQuery(),
joinConditions.stream()
.map(condition -> format(
"l.%s %s r.%s",
client.quoted(condition.getLeftColumn().getColumnName()),
condition.getOperator().getValue(),
client.quoted(condition.getRightColumn().getColumnName())))
.map(condition -> formatJoinCondition(client, condition))
.collect(joining(" AND ")));
List<QueryParameter> parameters = ImmutableList.<QueryParameter>builder()
.addAll(leftSource.getParameters())
Expand All @@ -133,6 +129,15 @@ public PreparedQuery prepareJoinQuery(
return new PreparedQuery(query, parameters);
}

protected String formatJoinCondition(JdbcClient client, JdbcJoinCondition condition)
{
return format(
"l.%s %s r.%s",
client.quoted(condition.getLeftColumn().getColumnName()),
condition.getOperator().getValue(),
client.quoted(condition.getRightColumn().getColumnName()));
}

protected String formatAssignments(JdbcClient client, String relationAlias, Map<JdbcColumnHandle, String> assignments)
{
return assignments.entrySet().stream()
Expand Down

0 comments on commit 0956887

Please sign in to comment.