Skip to content

Commit

Permalink
Removed the Changes for with Clause in DeleteStatement will raise it …
Browse files Browse the repository at this point in the history
…with a different PR.
  • Loading branch information
Yash-cor committed Dec 31, 2024
1 parent ff11f5e commit aa99360
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private static SubquerySegment bindSubquerySegment(final SubquerySegment segment
subqueryBinderContext.getExternalTableBinderContexts().putAll(binderContext.getExternalTableBinderContexts());
subqueryBinderContext.getCommonTableExpressionsSegmentsUniqueAliases().addAll(binderContext.getCommonTableExpressionsSegmentsUniqueAliases());
result.setSelect(new SelectStatementBinder(outerTableBinderContexts).bind(segment.getSelect(), subqueryBinderContext));
binderContext.getCommonTableExpressionsSegmentsUniqueAliases().addAll(subqueryBinderContext.getCommonTableExpressionsSegmentsUniqueAliases());
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public static SubquerySegment bind(final SubquerySegment segment, final SQLState
selectBinderContext.getExternalTableBinderContexts().putAll(binderContext.getExternalTableBinderContexts());
selectBinderContext.getCommonTableExpressionsSegmentsUniqueAliases().addAll(binderContext.getCommonTableExpressionsSegmentsUniqueAliases());
SelectStatement boundSelectStatement = new SelectStatementBinder(outerTableBinderContexts).bind(segment.getSelect(), selectBinderContext);
binderContext.getCommonTableExpressionsSegmentsUniqueAliases().addAll(selectBinderContext.getCommonTableExpressionsSegmentsUniqueAliases());
return new SubquerySegment(segment.getStartIndex(), segment.getStopIndex(), boundSelectStatement, segment.getText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public final class CommonTableExpressionSegmentBinder {
* @return bound common table expression segment
*/
public static CommonTableExpressionSegment bind(final CommonTableExpressionSegment segment, final SQLStatementBinderContext binderContext, final boolean recursive) {
if( segment.getAliasName().isPresent() ) {
ShardingSpherePreconditions.checkState(!binderContext.getCommonTableExpressionsSegmentsUniqueAliases().contains(segment.getAliasName().get()) ,
() -> new UniqueCommonTableExpressionException( segment.getAliasName().get() ));
if (segment.getAliasName().isPresent()) {
ShardingSpherePreconditions.checkState(!binderContext.getCommonTableExpressionsSegmentsUniqueAliases().contains(segment.getAliasName().get()),
() -> new UniqueCommonTableExpressionException(segment.getAliasName().get()));
binderContext.getCommonTableExpressionsSegmentsUniqueAliases().add(segment.getAliasName().get());
}
if (recursive && segment.getAliasName().isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void assertBind() {
assertTrue(binderContext.getExternalTableBinderContexts().containsKey(new CaseInsensitiveString("cte")));
assertTrue(actual.getCommonTableExpressions().iterator().next().getAliasName().isPresent());
assertThat(actual.getCommonTableExpressions().iterator().next().getAliasName().get(), is("cte"));
assertThat(binderContext.getCommonTableExpressionsSegmentsUniqueAliases().iterator().next(), is(new CaseInsensitiveString("cte")));
assertThat(binderContext.getCommonTableExpressionsSegmentsUniqueAliases().iterator().next(), is("cte"));

SimpleTableSegmentBinderContext simpleTableSegment = (SimpleTableSegmentBinderContext) binderContext.getExternalTableBinderContexts().get(new CaseInsensitiveString("cte")).iterator().next();
ArrayList<ColumnProjectionSegment> columnProjectionSegments = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.ReturningSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.order.OrderBySegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.pagination.limit.LimitSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.WithSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.DeleteStatement;
import org.apache.shardingsphere.sql.parser.statement.mysql.MySQLStatement;

Expand All @@ -38,9 +37,7 @@ public final class MySQLDeleteStatement extends DeleteStatement implements MySQL
private LimitSegment limit;

private ReturningSegment returningSegment;

private WithSegment withSegment;


@Override
public Optional<OrderBySegment> getOrderBy() {
return Optional.ofNullable(orderBy);
Expand All @@ -55,10 +52,4 @@ public Optional<LimitSegment> getLimit() {
public Optional<ReturningSegment> getReturningSegment() {
return Optional.ofNullable(returningSegment);
}

@Override
public Optional<WithSegment> getWithSegment() {
return Optional.ofNullable(withSegment);
}

}

0 comments on commit aa99360

Please sign in to comment.