Skip to content

Commit eccdfd9

Browse files
committed
test set variable with all dialects
1 parent beea046 commit eccdfd9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/webserver/database/sql.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,30 @@ mod test {
999999
);
10001000
}
10011001

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+
10021026
#[test]
10031027
fn test_static_extract_doesnt_match() {
10041028
assert_eq!(

0 commit comments

Comments
 (0)