diff --git a/create.go b/create.go index 556aae0..35dcd6e 100644 --- a/create.go +++ b/create.go @@ -78,15 +78,15 @@ func (d *createData) ToSQL() (sqlStr string, args []interface{}, err error) { sql.WriteString("CREATE TABLE ") if d.Schema != "" { - sql.WriteString("`" + d.Schema + "`.") + sql.WriteString("\"" + d.Schema + "\".") } - sql.WriteString("`" + d.TableName + "`") + sql.WriteString("\"" + d.TableName + "\"") sql.WriteString(" ") var columnTypes []string for i := 0; i < len(d.Columns); i++ { - columnTypes = append(columnTypes, "`"+d.Columns[i]+"` "+d.Types[i]) + columnTypes = append(columnTypes, "\""+d.Columns[i]+"\" "+d.Types[i]) } sql.WriteString("(") @@ -99,7 +99,7 @@ func (d *createData) ToSQL() (sqlStr string, args []interface{}, err error) { return } sql.WriteString(" ") - sql.WriteString("ALTER TABLE `" + d.TableName + "` ADD PRIMARY KEY (`" + d.Primary + "`);") + sql.WriteString("ALTER TABLE \"" + d.TableName + "\" ADD PRIMARY KEY (\"" + d.Primary + "\");") } if d.Unique != "" { @@ -108,7 +108,7 @@ func (d *createData) ToSQL() (sqlStr string, args []interface{}, err error) { return } sql.WriteString(" ") - sql.WriteString("ALTER TABLE `" + d.TableName + "` ADD UNIQUE (`" + d.Unique + "`);") + sql.WriteString("ALTER TABLE \"" + d.TableName + "\" ADD UNIQUE (\"" + d.Unique + "\");") } sqlStr = sql.String() return diff --git a/create_test.go b/create_test.go index fdd217a..be570f9 100644 --- a/create_test.go +++ b/create_test.go @@ -12,7 +12,7 @@ func TestCreate(t *testing.T) { if err != nil { t.Fatal(err.Error()) } - result := "CREATE TABLE `users` (`name` varchar(255), `password` text, `date` date);" + result := "CREATE TABLE \"users\" (\"name\" varchar(255), \"password\" text, \"date\" date);" if sql != result { t.Fatal("sql is not equal to result:", sql) } @@ -28,7 +28,7 @@ func TestCreate(t *testing.T) { if err != nil { t.Fatal(err.Error()) } - result := "CREATE TABLE `users` (`id` uuid, `name` varchar(255), `email` varchar(255), `password` text, `date` date); ALTER TABLE `users` ADD PRIMARY KEY (`id`); ALTER TABLE `users` ADD UNIQUE (`email`);" + result := "CREATE TABLE \"users\" (\"id\" uuid, \"name\" varchar(255), \"email\" varchar(255), \"password\" text, \"date\" date); ALTER TABLE \"users\" ADD PRIMARY KEY (\"id\"); ALTER TABLE \"users\" ADD UNIQUE (\"email\");" if sql != result { t.Fatal("sql is not equal to result:", sql) } @@ -39,7 +39,7 @@ func TestCreate(t *testing.T) { if err != nil { t.Fatal(err.Error()) } - result := "CREATE TABLE `private`.`users` (`name` varchar(255), `password` text, `date` date);" + result := "CREATE TABLE \"private\".\"users\" (\"name\" varchar(255), \"password\" text, \"date\" date);" if sql != result { t.Fatal("sql is not equal to result:", sql) }