Skip to content

Commit

Permalink
Update firebird delete statement to support returning
Browse files Browse the repository at this point in the history
  • Loading branch information
makssent committed Dec 13, 2024
1 parent 4f3123f commit 0bb8eb1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ blobValue
;

delete
: DELETE singleTableClause whereClause?
: DELETE singleTableClause whereClause? returningClause?
;

singleTableClause
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ public ASTNode visitDelete(final DeleteContext ctx) {
result.setWhere((WhereSegment) visit(ctx.whereClause()));
}
result.addParameterMarkerSegments(getParameterMarkerSegments());
if (null != ctx.returningClause()) {
result.setReturningSegment((ReturningSegment) visit(ctx.returningClause()));
}
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,23 @@

package org.apache.shardingsphere.sql.parser.statement.firebird.dml;

import lombok.Setter;
import org.apache.shardingsphere.sql.parser.statement.core.segment.dml.ReturningSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.DeleteStatement;
import org.apache.shardingsphere.sql.parser.statement.firebird.FirebirdStatement;

import java.util.Optional;

/**
* Firebird delete statement.
*/
@Setter
public final class FirebirdDeleteStatement extends DeleteStatement implements FirebirdStatement {

private ReturningSegment returningSegment;

@Override
public Optional<ReturningSegment> getReturningSegment() {
return Optional.ofNullable(returningSegment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
<sql-case id="delete_with_schema" value="DELETE FROM db1.t_order" />
<sql-case id="delete_with_simple_condition" value="DELETE FROM Q1_2000_sales WHERE amount_sold &lt; 0" db-types="Oracle" />
<sql-case id="delete_with_output_clause_with_compress_function" value="DELETE FROM player OUTPUT deleted.id,deleted.name, deleted.surname,deleted.datemodifier,COMPRESS(deleted.info) INTO dbo.inactivePlayers WHERE datemodified &lt; @startOfYear" db-types="SQLServer" />
<sql-case id="delete_returning_expressions" value="DELETE FROM t2 WHERE id = 2 RETURNING id,t&amp;t" db-types="MySQL" />
<sql-case id="delete_returning_expressions" value="DELETE FROM t2 WHERE id = 2 RETURNING id,t&amp;t" db-types="MySQL,Firebird" />
</sql-cases>

0 comments on commit 0bb8eb1

Please sign in to comment.