File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -999,6 +999,30 @@ mod test {
999
999
) ;
1000
1000
}
1001
1001
1002
+ #[ test]
1003
+ fn test_extract_set_variable ( ) {
1004
+ let sql = "set x = 42" ;
1005
+ for & ( dialect, db_kind) in ALL_DIALECTS {
1006
+ let mut parser = Parser :: new ( dialect) . try_with_sql ( sql) . unwrap ( ) ;
1007
+ let stmt = parse_single_statement ( & mut parser, db_kind, sql) ;
1008
+ if let Some ( ParsedStatement :: SetVariable {
1009
+ variable,
1010
+ value : StmtWithParams { query, params, .. } ,
1011
+ } ) = stmt
1012
+ {
1013
+ assert_eq ! (
1014
+ variable,
1015
+ StmtParam :: PostOrGet ( "x" . to_string( ) ) ,
1016
+ "{dialect:?}"
1017
+ ) ;
1018
+ assert_eq ! ( query, "SELECT 42" ) ;
1019
+ assert ! ( params. is_empty( ) ) ;
1020
+ } else {
1021
+ panic ! ( "Failed for dialect {dialect:?}: {stmt:#?}" , ) ;
1022
+ }
1023
+ }
1024
+ }
1025
+
1002
1026
#[ test]
1003
1027
fn test_static_extract_doesnt_match ( ) {
1004
1028
assert_eq ! (
You can’t perform that action at this time.
0 commit comments