feat: Support SET NAMES literal [COLLATE literal] (#558)

* feat: Support SET NAMES literal [COLLATE literal]

* feat: Support SET NAMES DEFAULT

* clippy
This commit is contained in:
Dmitry Patsura 2022-08-11 13:55:55 +03:00 committed by GitHub
parent aabafc9fc8
commit 221e9c2bab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 84 additions and 1 deletions

View file

@ -890,6 +890,41 @@ fn parse_table_colum_option_on_update() {
}
}
#[test]
fn parse_set_names() {
let stmt = mysql_and_generic().verified_stmt("SET NAMES utf8mb4");
assert_eq!(
stmt,
Statement::SetNames {
charset_name: "utf8mb4".to_string(),
collation_name: None,
}
);
let stmt = mysql_and_generic().verified_stmt("SET NAMES utf8mb4 COLLATE bogus");
assert_eq!(
stmt,
Statement::SetNames {
charset_name: "utf8mb4".to_string(),
collation_name: Some("bogus".to_string()),
}
);
let stmt = mysql_and_generic()
.parse_sql_statements("set names utf8mb4 collate bogus")
.unwrap();
assert_eq!(
stmt,
vec![Statement::SetNames {
charset_name: "utf8mb4".to_string(),
collation_name: Some("bogus".to_string()),
}]
);
let stmt = mysql_and_generic().verified_stmt("SET NAMES DEFAULT");
assert_eq!(stmt, Statement::SetNamesDefault {});
}
fn mysql() -> TestedDialects {
TestedDialects {
dialects: vec![Box::new(MySqlDialect {})],