Skip to content

Commit 0d30912

Browse files
committed
Enable new features unconditionally
1 parent 44265b1 commit 0d30912

File tree

6 files changed

+8
-211
lines changed

6 files changed

+8
-211
lines changed

src/ast/dml.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,6 @@ pub struct MergeInsertExpr {
545545
/// The insert type used by the statement.
546546
pub kind: MergeInsertKind,
547547
/// An optional condition to restrict the insertion (Oracle specific)
548-
///
549-
/// Enabled via [`Dialect::supports_merge_insert_predicate`](crate::dialect::Dialect::supports_merge_insert_predicate).
550548
pub insert_predicate: Option<Expr>,
551549
}
552550

@@ -582,12 +580,8 @@ pub struct MergeUpdateExpr {
582580
/// The update assiment expressions
583581
pub assignments: Vec<Assignment>,
584582
/// `where_clause` for the update (Oralce specific)
585-
///
586-
/// Enabled via [`Dialect::supports_merge_update_predicate`](crate::dialect::Dialect::supports_merge_update_predicate).
587583
pub update_predicate: Option<Expr>,
588584
/// `delete_clause` for the update "delete where" (Oracle specific)
589-
///
590-
/// Enabled via [`Dialect::supports_merge_update_delete_predicate`](crate::dialect::Dialect::supports_merge_update_delete_predicate).
591585
pub delete_predicate: Option<Expr>,
592586
}
593587

src/dialect/mod.rs

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -608,119 +608,6 @@ pub trait Dialect: Debug + Any {
608608
false
609609
}
610610

611-
/// Returns `true` if the dialect supports qualified column names
612-
/// as part of a MERGE's INSERT's column list. Example:
613-
///
614-
/// ```sql
615-
/// MERGE INTO FOO
616-
/// USING FOO_IMP
617-
/// ON (FOO.ID = FOO_IMP.ID)
618-
/// WHEN NOT MATCHED THEN
619-
/// -- no qualifier
620-
/// INSERT (ID, NAME)
621-
/// VALUES (FOO_IMP.ID, UPPER(FOO_IMP.NAME))
622-
/// ```
623-
/// vs.
624-
/// ```sql
625-
/// MERGE INTO FOO
626-
/// USING FOO_IMP
627-
/// ON (FOO.ID = FOO_IMP.ID)
628-
/// WHEN NOT MATCHED THEN
629-
/// -- here: qualified
630-
/// INSERT (FOO.ID, FOO.NAME)
631-
/// VALUES (FOO_IMP.ID, UPPER(FOO_IMP.NAME))
632-
/// ```
633-
/// or
634-
/// ```sql
635-
/// MERGE INTO FOO
636-
/// USING FOO_IMP
637-
/// ON (FOO.ID = FOO_IMP.ID)
638-
/// WHEN NOT MATCHED THEN
639-
/// -- here: qualified with array subscripts
640-
/// INSERT (FOO.ID[1], FOO.NAME[1:12])
641-
/// VALUES (FOO_IMP.ID, UPPER(FOO_IMP.NAME))
642-
/// ```
643-
/// or
644-
/// ```sql
645-
/// MERGE INTO FOO X
646-
/// USING FOO_IMP
647-
/// ON (X.ID = FOO_IMP.ID)
648-
/// WHEN NOT MATCHED THEN
649-
/// -- here: qualified using the alias
650-
/// INSERT (X.ID, X.NAME)
651-
/// VALUES (FOO_IMP.ID, UPPER(FOO_IMP.NAME))
652-
/// ```
653-
///
654-
/// By default, qualifiers are allowed.
655-
fn supports_merge_insert_qualified_columns(&self) -> bool {
656-
true
657-
}
658-
659-
/// Returns `true` if the dialect supports specify an INSERT predicate in
660-
/// MERGE statements. Example:
661-
///
662-
/// ```sql
663-
/// MERGE INTO FOO
664-
/// USING FOO_IMP
665-
/// ON (FOO.ID = FOO_IMP.ID)
666-
/// WHEN NOT MATCHED THEN
667-
/// INSERT (ID, NAME)
668-
/// VALUES (FOO_IMP.ID, UPPER(FOO_IMP.NAME))
669-
/// -- insert predicate
670-
/// WHERE NOT FOO_IMP.NAME like '%.IGNORE'
671-
/// ```
672-
///
673-
/// By default, the additional predicate support is enabled.
674-
///
675-
/// See also [Dialect::supports_merge_update_predicate] and
676-
/// [Dialect::supports_merge_update_delete_predicate].
677-
fn supports_merge_insert_predicate(&self) -> bool {
678-
true
679-
}
680-
681-
/// Indicates the supports of UPDATE predicates in MERGE
682-
/// statements. Example:
683-
///
684-
/// ```sql
685-
/// MERGE INTO FOO
686-
/// USING FOO_IMPORT
687-
/// ON (FOO.ID = FOO_IMPORT.ID)
688-
/// WHEN MATCHED THEN
689-
/// UPDATE SET FOO.NAME = FOO_IMPORT.NAME
690-
/// -- update predicate
691-
/// WHERE FOO.NAME <> 'pete'
692-
/// ```
693-
///
694-
/// By default, the additional predicate is enabled.
695-
///
696-
/// See also [Dialect::supports_merge_insert_predicate] and
697-
/// [Dialect::supports_merge_update_delete_predicate].
698-
fn supports_merge_update_predicate(&self) -> bool {
699-
true
700-
}
701-
702-
/// Indicates the supports of UPDATE ... DELETEs and associated predicates
703-
/// in MERGE statements. Example:
704-
///
705-
/// ```sql
706-
/// MERGE INTO FOO
707-
/// USING FOO_IMPORT
708-
/// ON (FOO.ID = FOO_IMPORT.ID)
709-
/// WHEN MATCHED THEN
710-
/// UPDATE SET FOO.NAME = FOO_IMPORT.NAME
711-
/// -- update delete with predicate
712-
/// DELETE WHERE UPPER(FOO.NAME) == FOO.NAME
713-
/// ```
714-
///
715-
/// By default, the support for the `UPDATE ... DELETE` and its associated
716-
/// predicate is enabled.
717-
///
718-
/// See also [Dialect::supports_merge_insert_predicate] and
719-
/// [Dialect::supports_merge_update_predicate].
720-
fn supports_merge_update_delete_predicate(&self) -> bool {
721-
true
722-
}
723-
724611
/// Dialect-specific infix parser override
725612
///
726613
/// This method is called to parse the next infix expression.

src/dialect/mssql.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -123,26 +123,6 @@ impl Dialect for MsSqlDialect {
123123
true
124124
}
125125

126-
/// Set <https://learn.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql>
127-
fn supports_merge_insert_predicate(&self) -> bool {
128-
false
129-
}
130-
131-
/// Set <https://learn.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql>
132-
fn supports_merge_insert_qualified_columns(&self) -> bool {
133-
false
134-
}
135-
136-
/// Set <https://learn.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql>
137-
fn supports_merge_update_delete_predicate(&self) -> bool {
138-
false
139-
}
140-
141-
/// Set <https://learn.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql>
142-
fn supports_merge_update_predicate(&self) -> bool {
143-
false
144-
}
145-
146126
/// See <https://learn.microsoft.com/en-us/sql/relational-databases/security/authentication-access/server-level-roles>
147127
fn get_reserved_grantees_types(&self) -> &[GranteesType] {
148128
&[GranteesType::Public]

src/dialect/postgresql.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,4 @@ impl Dialect for PostgreSqlDialect {
280280
fn supports_interval_options(&self) -> bool {
281281
true
282282
}
283-
284-
/// See <https://www.postgresql.org/docs/current/sql-merge.html>
285-
fn supports_merge_insert_predicate(&self) -> bool {
286-
false
287-
}
288-
289-
/// See <https://www.postgresql.org/docs/current/sql-merge.html>
290-
fn supports_merge_update_delete_predicate(&self) -> bool {
291-
false
292-
}
293-
294-
/// See <https://www.postgresql.org/docs/current/sql-merge.html>
295-
fn supports_merge_update_predicate(&self) -> bool {
296-
false
297-
}
298283
}

src/parser/merge.rs

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use alloc::{boxed::Box, format, string::ToString, vec, vec::Vec};
1818
use crate::{
1919
ast::{
2020
Merge, MergeAction, MergeClause, MergeClauseKind, MergeInsertExpr, MergeInsertKind,
21-
MergeUpdateExpr, ObjectName, ObjectNamePart, OutputClause, SetExpr, Statement,
21+
MergeUpdateExpr, ObjectName, OutputClause, SetExpr, Statement,
2222
},
2323
dialect::{BigQueryDialect, GenericDialect, MySqlDialect},
2424
keywords::Keyword,
@@ -116,16 +116,12 @@ impl Parser<'_> {
116116
let update_token = self.get_current_token().clone();
117117
self.expect_keyword_is(Keyword::SET)?;
118118
let assignments = self.parse_comma_separated(Parser::parse_assignment)?;
119-
let update_predicate = if self.dialect.supports_merge_update_predicate()
120-
&& self.parse_keyword(Keyword::WHERE)
121-
{
119+
let update_predicate = if self.parse_keyword(Keyword::WHERE) {
122120
Some(self.parse_expr()?)
123121
} else {
124122
None
125123
};
126-
let delete_predicate = if self.dialect.supports_merge_update_delete_predicate()
127-
&& self.parse_keyword(Keyword::DELETE)
128-
{
124+
let delete_predicate = if self.parse_keyword(Keyword::DELETE) {
129125
let _ = self.expect_keyword(Keyword::WHERE)?;
130126
Some(self.parse_expr()?)
131127
} else {
@@ -179,9 +175,7 @@ impl Parser<'_> {
179175
let values = self.parse_values(is_mysql, false)?;
180176
(MergeInsertKind::Values(values), values_token)
181177
};
182-
let insert_predicate = if self.dialect.supports_merge_insert_predicate()
183-
&& self.parse_keyword(Keyword::WHERE)
184-
{
178+
let insert_predicate = if self.parse_keyword(Keyword::WHERE) {
185179
Some(self.parse_expr()?)
186180
} else {
187181
None
@@ -216,25 +210,7 @@ impl Parser<'_> {
216210
&mut self,
217211
allow_empty: bool,
218212
) -> Result<Vec<ObjectName>, ParserError> {
219-
if self.dialect.supports_merge_insert_qualified_columns() {
220-
self.parse_parenthesized_qualified_column_list(IsOptional::Optional, allow_empty)
221-
} else {
222-
self.parse_parenthesized_column_list_as_object_names(IsOptional::Optional, allow_empty)
223-
}
224-
}
225-
226-
/// Just like [Parser::parse_parenthesized_column_list] parses a
227-
/// parenthesized list of (simple) column names but returns them as object
228-
/// names.
229-
fn parse_parenthesized_column_list_as_object_names(
230-
&mut self,
231-
optional: IsOptional,
232-
allow_empty: bool,
233-
) -> Result<Vec<ObjectName>, ParserError> {
234-
self.parse_parenthesized_column_list_inner(optional, allow_empty, |p| {
235-
p.parse_identifier()
236-
.map(|ident| ObjectName(vec![ObjectNamePart::Identifier(ident)]))
237-
})
213+
self.parse_parenthesized_qualified_column_list(IsOptional::Optional, allow_empty)
238214
}
239215

240216
fn parse_output(

tests/sqlparser_common.rs

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,14 +1637,6 @@ fn ms_and_generic() -> TestedDialects {
16371637
TestedDialects::new(vec![Box::new(MsSqlDialect {}), Box::new(GenericDialect {})])
16381638
}
16391639

1640-
fn only_ms() -> TestedDialects {
1641-
TestedDialects::new(vec![Box::new(MsSqlDialect {})])
1642-
}
1643-
1644-
fn only_generic() -> TestedDialects {
1645-
TestedDialects::new(vec![Box::new(GenericDialect {})])
1646-
}
1647-
16481640
#[test]
16491641
fn parse_json_ops_without_colon() {
16501642
use self::BinaryOperator::*;
@@ -10097,7 +10089,7 @@ WHEN NOT MATCHED THEN \
1009710089
INSERT (ID, NAME) \
1009810090
VALUES (FOO_IMPORT.ID, UPPER(FOO_IMPORT.NAME)) \
1009910091
WHERE NOT FOO_IMPORT.NAME LIKE '%.DO_NOT_INSERT'";
10100-
only_generic().verified_stmt(sql);
10092+
all_dialects().verified_stmt(sql);
1010110093
}
1010210094

1010310095
#[test]
@@ -10117,7 +10109,7 @@ MERGE INTO FOO USING FOO_IMPORT ON (FOO.ID = FOO_IMPORT.ID) \
1011710109
WHEN NOT MATCHED THEN \
1011810110
INSERT (FOO.ID, FOO.NAME) \
1011910111
VALUES (1, 'abc')";
10120-
pg_and_generic().verified_stmt(sql);
10112+
all_dialects().verified_stmt(sql);
1012110113
}
1012210114

1012310115
#[test]
@@ -10127,24 +10119,7 @@ MERGE INTO PLAYGROUND.FOO USING FOO_IMPORT ON (PLAYGROUND.FOO.ID = FOO_IMPORT.ID
1012710119
WHEN NOT MATCHED THEN \
1012810120
INSERT (PLAYGROUND.FOO.ID, PLAYGROUND.FOO.NAME) \
1012910121
VALUES (1, 'abc')";
10130-
pg_and_generic().verified_stmt(sql);
10131-
}
10132-
10133-
#[test]
10134-
fn test_merge_insert_with_qualified_columns_not_supported() {
10135-
let sql = "\
10136-
MERGE INTO FOO USING FOO_IMPORT ON (FOO.ID = FOO_IMPORT.ID) \
10137-
WHEN NOT MATCHED THEN \
10138-
INSERT (FOO.ID, FOO.NAME) \
10139-
VALUES (1, 'abc')";
10140-
assert!(only_ms().parse_sql_statements(sql).is_err());
10141-
10142-
let sql = "\
10143-
MERGE INTO PLAYGROUND.FOO USING FOO_IMPORT ON (PLAYGROUND.FOO.ID = FOO_IMPORT.ID) \
10144-
WHEN NOT MATCHED THEN \
10145-
INSERT (PLAYGROUND.FOO.ID, PLAYGROUND.FOO.NAME) \
10146-
VALUES (1, 'abc')";
10147-
assert!(only_ms().parse_sql_statements(sql).is_err());
10122+
all_dialects().verified_stmt(sql);
1014810123
}
1014910124

1015010125
#[test]

0 commit comments

Comments
 (0)