Add negative tests for POSITION (#469)

This commit is contained in:
Andrew Lamb 2022-04-25 07:21:06 -04:00 committed by GitHub
parent 8f4f01e517
commit edad20cbb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4601,3 +4601,20 @@ fn parse_position() {
expr_from_projection(only(&select.projection))
);
}
#[test]
fn parse_position_negative() {
let sql = "SELECT POSITION(foo) from bar";
let res = parse_sql_statements(sql);
assert_eq!(
ParserError::ParserError("Position function must include IN keyword".to_string()),
res.unwrap_err()
);
let sql = "SELECT POSITION(foo IN) from bar";
let res = parse_sql_statements(sql);
assert_eq!(
ParserError::ParserError("Expected an expression:, found: )".to_string()),
res.unwrap_err()
);
}