Commit 238383de authored by Vladimir Iakovlev's avatar Vladimir Iakovlev Committed by Katharina Fey
Browse files

Use correct syntax for `CREATE TABLE IF NOT EXISTS` and `DROP TABLE IF EXISTS` in MySql backend

parent 20caf2c4
......@@ -23,7 +23,7 @@ impl SqlGenerator for MySql {
}
fn create_table_if_not_exists(name: &str, schema: Option<&str>) -> String {
format!("CREATE TABLE {}`{}` IF NOT EXISTS", prefix!(schema), name)
format!("CREATE TABLE IF NOT EXISTS {}`{}`", prefix!(schema), name)
}
fn drop_table(name: &str, schema: Option<&str>) -> String {
......@@ -31,7 +31,7 @@ impl SqlGenerator for MySql {
}
fn drop_table_if_exists(name: &str, schema: Option<&str>) -> String {
format!("DROP TABLE {}`{}` IF EXISTS", prefix!(schema), name)
format!("DROP TABLE IF EXISTS {}`{}`", prefix!(schema), name)
}
fn rename_table(old: &str, new: &str, schema: Option<&str>) -> String {
......
......@@ -20,7 +20,7 @@ fn create_table_with_schema() {
fn create_table_if_not_exists() {
let sql = MySql::create_table_if_not_exists("table_to_create", None);
assert_eq!(
String::from("CREATE TABLE `table_to_create` IF NOT EXISTS"),
String::from("CREATE TABLE IF NOT EXISTS `table_to_create`"),
sql
);
}
......@@ -34,7 +34,7 @@ fn drop_table() {
#[test]
fn drop_table_if_exists() {
let sql = MySql::drop_table_if_exists("table_to_drop", None);
assert_eq!(String::from("DROP TABLE `table_to_drop` IF EXISTS"), sql);
assert_eq!(String::from("DROP TABLE IF EXISTS `table_to_drop`"), sql);
}
#[test]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment