mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 06:18:17 +00:00
Fix AS query clause should be after the create table options (#1339)
This commit is contained in:
parent
993216f3ac
commit
20f7ac59e3
4 changed files with 61 additions and 10 deletions
|
@ -812,6 +812,33 @@ fn parse_create_table_collate() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_table_both_options_and_as_query() {
|
||||
let sql = "CREATE TABLE foo (id INT(11)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb4_0900_ai_ci AS SELECT 1";
|
||||
match mysql_and_generic().verified_stmt(sql) {
|
||||
Statement::CreateTable(CreateTable {
|
||||
name,
|
||||
collation,
|
||||
query,
|
||||
..
|
||||
}) => {
|
||||
assert_eq!(name.to_string(), "foo");
|
||||
assert_eq!(collation, Some("utf8mb4_0900_ai_ci".to_string()));
|
||||
assert_eq!(
|
||||
query.unwrap().body.as_select().unwrap().projection,
|
||||
vec![SelectItem::UnnamedExpr(Expr::Value(number("1")))]
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let sql = r"CREATE TABLE foo (id INT(11)) ENGINE=InnoDB AS SELECT 1 DEFAULT CHARSET=utf8mb3";
|
||||
assert!(matches!(
|
||||
mysql_and_generic().parse_sql_statements(sql),
|
||||
Err(ParserError::ParserError(_))
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_table_comment_character_set() {
|
||||
let sql = "CREATE TABLE foo (s TEXT CHARACTER SET utf8mb4 COMMENT 'comment')";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue