mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-03 22:08:16 +00:00
Support identifiers quoted with backticks in the MySQL dialect (#247)
Per https://dev.mysql.com/doc/refman/8.0/en/identifiers.html MySQL historically supports `identifiers quoted in backticks` in addition to the ANSI "quoting style" (assuming ANSI_QUOTES mode).
This commit is contained in:
parent
1337820c06
commit
9e7e30282e
2 changed files with 28 additions and 1 deletions
|
@ -106,7 +106,7 @@ fn parse_create_table_auto_increment() {
|
|||
assert_eq!(name.to_string(), "foo");
|
||||
assert_eq!(
|
||||
vec![ColumnDef {
|
||||
name: "bar".into(),
|
||||
name: Ident::new("bar"),
|
||||
data_type: DataType::Int,
|
||||
collation: None,
|
||||
options: vec![
|
||||
|
@ -129,6 +129,29 @@ fn parse_create_table_auto_increment() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_quote_identifiers() {
|
||||
let sql = "CREATE TABLE `PRIMARY` (`BEGIN` INT PRIMARY KEY)";
|
||||
match mysql().verified_stmt(sql) {
|
||||
Statement::CreateTable { name, columns, .. } => {
|
||||
assert_eq!(name.to_string(), "`PRIMARY`");
|
||||
assert_eq!(
|
||||
vec![ColumnDef {
|
||||
name: Ident::with_quote('`', "BEGIN"),
|
||||
data_type: DataType::Int,
|
||||
collation: None,
|
||||
options: vec![ColumnOptionDef {
|
||||
name: None,
|
||||
option: ColumnOption::Unique { is_primary: true }
|
||||
}],
|
||||
}],
|
||||
columns
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn mysql() -> TestedDialects {
|
||||
TestedDialects {
|
||||
dialects: vec![Box::new(MySqlDialect {})],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue