Skip to content

Commit dbf412c

Browse files
committed
move EXECUTE tests to sqlparser_common
addresses apache#1490 and apache#1490
1 parent cf09440 commit dbf412c

File tree

2 files changed

+39
-35
lines changed

2 files changed

+39
-35
lines changed

tests/sqlparser_common.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,10 @@ fn pg_and_generic() -> TestedDialects {
13951395
])
13961396
}
13971397

1398+
fn ms_and_generic() -> TestedDialects {
1399+
TestedDialects::new(vec![Box::new(MsSqlDialect {}), Box::new(GenericDialect {})])
1400+
}
1401+
13981402
#[test]
13991403
fn parse_json_ops_without_colon() {
14001404
use self::BinaryOperator::*;
@@ -9730,6 +9734,41 @@ fn parse_call() {
97309734
);
97319735
}
97329736

9737+
#[test]
9738+
fn parse_execute_stored_procedure() {
9739+
let expected = Statement::Execute {
9740+
name: ObjectName(vec![
9741+
Ident {
9742+
value: "my_schema".to_string(),
9743+
quote_style: None,
9744+
},
9745+
Ident {
9746+
value: "my_stored_procedure".to_string(),
9747+
quote_style: None,
9748+
},
9749+
]),
9750+
parameters: vec![
9751+
Expr::Value(Value::NationalStringLiteral("param1".to_string())),
9752+
Expr::Value(Value::NationalStringLiteral("param2".to_string())),
9753+
],
9754+
has_parentheses: false,
9755+
using: vec![],
9756+
};
9757+
assert_eq!(
9758+
// Microsoft SQL Server does not use parentheses around arguments for EXECUTE
9759+
ms_and_generic()
9760+
.verified_stmt("EXECUTE my_schema.my_stored_procedure N'param1', N'param2'"),
9761+
expected
9762+
);
9763+
assert_eq!(
9764+
ms_and_generic().one_statement_parses_to(
9765+
"EXEC my_schema.my_stored_procedure N'param1', N'param2';",
9766+
"EXECUTE my_schema.my_stored_procedure N'param1', N'param2'",
9767+
),
9768+
expected
9769+
);
9770+
}
9771+
97339772
#[test]
97349773
fn parse_create_table_collate() {
97359774
pg_and_generic().verified_stmt("CREATE TABLE tbl (foo INT, bar TEXT COLLATE \"de_DE\")");

tests/sqlparser_mssql.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -570,41 +570,6 @@ fn parse_substring_in_select() {
570570
}
571571
}
572572

573-
#[test]
574-
fn parse_mssql_execute_stored_procedure() {
575-
let expected = Statement::Execute {
576-
name: ObjectName(vec![
577-
Ident {
578-
value: "my_schema".to_string(),
579-
quote_style: None,
580-
},
581-
Ident {
582-
value: "my_stored_procedure".to_string(),
583-
quote_style: None,
584-
},
585-
]),
586-
parameters: vec![
587-
Expr::Value(Value::NationalStringLiteral("param1".to_string())),
588-
Expr::Value(Value::NationalStringLiteral("param2".to_string())),
589-
],
590-
has_parentheses: false,
591-
using: vec![],
592-
};
593-
assert_eq!(
594-
ms().verified_stmt("EXECUTE my_schema.my_stored_procedure N'param1', N'param2'"),
595-
expected
596-
);
597-
assert_eq!(
598-
Parser::parse_sql(
599-
&MsSqlDialect {},
600-
"EXEC my_schema.my_stored_procedure N'param1', N'param2';"
601-
)
602-
.unwrap()[0],
603-
expected,
604-
"EXEC should be parsed the same as EXECUTE"
605-
);
606-
}
607-
608573
#[test]
609574
fn parse_mssql_declare() {
610575
let sql = "DECLARE @foo CURSOR, @bar INT, @baz AS TEXT = 'foobar';";

0 commit comments

Comments
 (0)