Skip to content

Commit

Permalink
Refactor ShadowColumnCondition (#33559)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Nov 6, 2024
1 parent 5e8dbbc commit a967dfb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Getter
public final class ShadowColumnCondition {

private final String owner;
private final String table;

private final String column;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class ColumnShadowAlgorithmDeterminer {
*/
public static boolean isShadow(final ColumnShadowAlgorithm<Comparable<?>> shadowAlgorithm, final ShadowCondition shadowCondition) {
for (PreciseColumnShadowValue<Comparable<?>> each : createColumnShadowValues(shadowCondition)) {
if (!shadowCondition.getTableName().equals(shadowCondition.getColumnCondition().getOwner()) || !shadowAlgorithm.isShadow(each)) {
if (!shadowCondition.getTableName().equals(shadowCondition.getColumnCondition().getTable()) || !shadowAlgorithm.isShadow(each)) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ private boolean isMatchColumnShadowAlgorithm(final String shadowTable, final Col
protected abstract Collection<ShadowColumnCondition> getShadowColumnConditions(String shadowColumnName);

protected final String getSingleTableName() {
return tableAliasAndNameMappings.entrySet().iterator().next().getValue();
return tableAliasAndNameMappings.values().iterator().next();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected Collection<ShadowColumnCondition> getShadowColumnConditions(final Stri
if (1 != columns.size()) {
continue;
}
ShadowExtractor.extractValues(each, parameters).map(values -> new ShadowColumnCondition(extractOwnerName(columns.iterator().next()), shadowColumnName, values)).ifPresent(result::add);
ShadowExtractor.extractValues(each, parameters).map(values -> new ShadowColumnCondition(getOwnerTableName(columns.iterator().next()), shadowColumnName, values)).ifPresent(result::add);
}
return result;
}
Expand All @@ -75,8 +75,8 @@ private Collection<ExpressionSegment> getWhereSegment() {
return result;
}

private String extractOwnerName(final ColumnSegment columnSegment) {
private String getOwnerTableName(final ColumnSegment columnSegment) {
Optional<OwnerSegment> owner = columnSegment.getOwner();
return owner.isPresent() ? getTableAliasAndNameMappings().get(owner.get().getIdentifier().getValue()) : getTableAliasAndNameMappings().keySet().iterator().next();
return owner.isPresent() ? getTableAliasAndNameMappings().get(owner.get().getIdentifier().getValue()) : getTableAliasAndNameMappings().values().iterator().next();
}
}

0 comments on commit a967dfb

Please sign in to comment.