@@ -2536,7 +2536,6 @@ DECLARE @Y AS NVARCHAR(MAX)='y'
25362536#[test]
25372537fn test_supports_statements_without_semicolon_delimiter() {
25382538 use sqlparser::ast::Ident;
2539-
25402539 use sqlparser::tokenizer::Location;
25412540
25422541 fn parse_n_statements(n: usize, sql: &str) -> Vec<Statement> {
@@ -2846,4 +2845,120 @@ fn test_supports_statements_without_semicolon_delimiter() {
28462845 },
28472846 }
28482847 );
2848+
2849+ let exec_then_update = "\
2850+ EXEC my_sp \
2851+ UPDATE my_table SET col = 1 \
2852+ ";
2853+ assert_eq!(
2854+ parse_n_statements(2, exec_then_update),
2855+ vec![
2856+ Statement::Execute {
2857+ name: Some(ObjectName::from(vec![Ident::new("my_sp")])),
2858+ parameters: vec![],
2859+ has_parentheses: false,
2860+ immediate: false,
2861+ into: vec![],
2862+ using: vec![],
2863+ output: false,
2864+ default: false,
2865+ },
2866+ Statement::Update {
2867+ table: TableWithJoins {
2868+ relation: TableFactor::Table {
2869+ name: ObjectName::from(vec![Ident::new("my_table")]),
2870+ alias: None,
2871+ with_hints: vec![],
2872+ args: None,
2873+ version: None,
2874+ with_ordinality: false,
2875+ partitions: vec![],
2876+ json_path: None,
2877+ sample: None,
2878+ index_hints: vec![]
2879+ },
2880+ joins: vec![],
2881+ },
2882+ assignments: vec![Assignment {
2883+ value: Expr::Value(
2884+ number("1")
2885+ .with_span(Span::new(Location::new(3, 16), Location::new(3, 17)))
2886+ ),
2887+ target: AssignmentTarget::ColumnName(ObjectName::from(vec![Ident::new("col")])),
2888+ },],
2889+ selection: None,
2890+ returning: None,
2891+ from: None,
2892+ or: None,
2893+ limit: None,
2894+ },
2895+ ]
2896+ );
2897+
2898+ let exec_params_then_update = "\
2899+ EXEC my_sp 1, 2 \
2900+ UPDATE my_table SET col = 1 \
2901+ ";
2902+ assert_eq!(
2903+ parse_n_statements(2, exec_params_then_update),
2904+ vec![
2905+ Statement::Execute {
2906+ name: Some(ObjectName::from(vec![Ident::with_span(
2907+ Span::new(Location::new(1, 6), Location::new(1, 11)),
2908+ "my_sp"
2909+ )])),
2910+ parameters: vec![
2911+ Expr::Value(
2912+ number("1")
2913+ .with_span(Span::new(Location::new(1, 12), Location::new(1, 13)))
2914+ ),
2915+ Expr::Value(
2916+ number("2")
2917+ .with_span(Span::new(Location::new(1, 15), Location::new(1, 17)))
2918+ ),
2919+ ],
2920+ has_parentheses: false,
2921+ immediate: false,
2922+ into: vec![],
2923+ using: vec![],
2924+ output: false,
2925+ default: false,
2926+ },
2927+ Statement::Update {
2928+ table: TableWithJoins {
2929+ relation: TableFactor::Table {
2930+ name: ObjectName::from(vec![Ident::with_span(
2931+ Span::new(Location::new(1, 24), Location::new(1, 32)),
2932+ "my_table"
2933+ )]),
2934+ alias: None,
2935+ with_hints: vec![],
2936+ args: None,
2937+ version: None,
2938+ with_ordinality: false,
2939+ partitions: vec![],
2940+ json_path: None,
2941+ sample: None,
2942+ index_hints: vec![]
2943+ },
2944+ joins: vec![],
2945+ },
2946+ assignments: vec![Assignment {
2947+ value: Expr::Value(
2948+ number("1")
2949+ .with_span(Span::new(Location::new(3, 16), Location::new(3, 17)))
2950+ ),
2951+ target: AssignmentTarget::ColumnName(ObjectName::from(vec![Ident::with_span(
2952+ Span::new(Location::new(1, 37), Location::new(1, 40)),
2953+ "col"
2954+ )])),
2955+ },],
2956+ selection: None,
2957+ returning: None,
2958+ from: None,
2959+ or: None,
2960+ limit: None,
2961+ },
2962+ ]
2963+ );
28492964}
0 commit comments