Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using own Feature - constant for "delete with returning" #1597 #1598

Merged
merged 1 commit into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/main/java/net/sf/jsqlparser/parser/feature/Feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,11 @@ public enum Feature {
updateUseSelect,
updateOrderBy,
updateLimit,
/**
* "RETURNING expr(, expr)*"
*
* @see SelectExpressionItem
*/
updateReturning,
/**
* SQL "DELETE" statement is allowed
Expand All @@ -350,6 +355,12 @@ public enum Feature {
* "ORDER BY ..."
*/
deleteOrderBy,
/**
* "RETURNING expr(, expr)*"
*
* @see SelectExpressionItem
*/
deleteReturningExpressionList,

/**
* SQL "UPSERT" statement is allowed
Expand Down Expand Up @@ -501,7 +512,7 @@ public enum Feature {
*/
createTableRowMovement,
/**
* "CREATE TABLE (colspec) SELECT ...
* "CREATE TABLE (colspec) SELECT ...
*/
createTableFromSelect,
/**
Expand Down Expand Up @@ -615,7 +626,7 @@ public enum Feature {
set,
/**
* @see ResetStatement
*/
*/
reset,
/**
* @see Pivot
Expand Down Expand Up @@ -724,17 +735,18 @@ public enum Feature {
allowSquareBracketQuotation(false),

/**
allow parsing of RDBMS specific syntax by switching off SQL Standard Compliant Syntax
*/
* allow parsing of RDBMS specific syntax by switching off SQL Standard
* Compliant Syntax
*/
allowPostgresSpecificSyntax(false),

// PERFORMANCE

/**
* allows complex expression parameters or named parameters for functions
* will be switched off, when deep nesting of functions is detected
*/
allowComplexParsing(true),
allowComplexParsing(true),

/**
* allows passing through Unsupported Statements as a plain List of Tokens
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public class FeaturesAllowed implements FeatureSetValidation, ModifyableFeatureS
* all {@link Feature}' for SQL UPDATE including {@link #SELECT}
*/
public static final FeaturesAllowed DELETE = new FeaturesAllowed("DELETE", Feature.delete, Feature.deleteJoin,
Feature.deleteLimit, Feature.deleteOrderBy, Feature.deleteTables, Feature.truncate)
Feature.deleteLimit, Feature.deleteOrderBy, Feature.deleteTables, Feature.deleteReturningExpressionList,
Feature.truncate)
.add(SELECT).unmodifyable();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public enum OracleVersion implements Version {

// https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/DELETE.html
Feature.delete,
Feature.deleteReturningExpressionList,

// https://www.oracletutorial.com/oracle-basics/oracle-truncate-table/
Feature.truncate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public enum PostgresqlVersion implements Version {
// https://www.postgresql.org/docs/current/sql-createindex.html
Feature.createIndex,
// https://www.postgresql.org/docs/current/sql-createtable.html
Feature.createTable, Feature.createTableUnlogged,
Feature.createTable, Feature.createTableUnlogged,
Feature.createTableCreateOptionStrings, Feature.createTableTableOptionStrings,
Feature.createTableFromSelect, Feature.createTableIfNotExists,
// https://www.postgresql.org/docs/current/sql-createview.html
Expand All @@ -111,12 +111,14 @@ public enum PostgresqlVersion implements Version {
Feature.insertValues,
Feature.values,
Feature.insertFromSelect,
Feature.insertReturningAll, Feature.insertReturningExpressionList,
Feature.insertReturningAll,
Feature.insertReturningExpressionList,
// https://www.postgresql.org/docs/current/sql-update.html
Feature.update,
Feature.updateReturning,
// https://www.postgresql.org/docs/current/sql-delete.html
Feature.delete,
Feature.deleteReturningExpressionList,
// https://www.postgresql.org/docs/current/sql-truncate.html
Feature.truncate,

Expand Down Expand Up @@ -150,7 +152,10 @@ public enum PostgresqlVersion implements Version {
// https://www.postgresql.org/docs/current/sql-commit.html
Feature.commit
)),
V11("11", V10.copy().getFeatures()), V12("12", V11.copy().getFeatures());
V11("11", V10.copy().getFeatures()),
V12("12", V11.copy().getFeatures()),
V13("13", V12.copy().getFeatures()),
V14("14", V13.copy().getFeatures());

private Set<Feature> features;
private String versionString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void validate(Delete delete) {
validateOptionalFeature(c, delete.getJoins(), Feature.deleteJoin);
validateOptionalFeature(c, delete.getLimit(), Feature.deleteLimit);
validateOptionalFeature(c, delete.getOrderByElements(), Feature.deleteOrderBy);
validateOptionalFeature(c, delete.getReturningExpressionList(), Feature.insertReturningExpressionList);
validateOptionalFeature(c, delete.getReturningExpressionList(), Feature.deleteReturningExpressionList);
}

SelectValidator v = getValidator(SelectValidator.class);
Expand Down