From 0c4e43cd7ab20f14469bb5059f4262c0dd969567 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sun, 3 Nov 2013 21:19:38 +0800 Subject: [PATCH] Don't quote table names --- README.md | 2 +- do.go | 6 +++--- gorm_test.go | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 97169ccd..01075d7d 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ db.Where("name <> ?", "jinzhu").Find(&users) //// SELECT * FROM users WHERE name <> 'jinzhu'; // IN -db.Where("name in (?)", []string["jinzhu", "jinzhu 2"]).Find(&users) +db.Where("name in (?)", []string{"jinzhu", "jinzhu 2"}).Find(&users) //// SELECT * FROM users WHERE name IN ('jinzhu', 'jinzhu 2'); // LIKE diff --git a/do.go b/do.go index 20744818..c9086152 100644 --- a/do.go +++ b/do.go @@ -106,7 +106,7 @@ func (s *Do) prepareCreateSql() { } s.sql = fmt.Sprintf( - "INSERT INTO \"%v\" (%v) VALUES (%v) %v", + "INSERT INTO %v (%v) VALUES (%v) %v", s.tableName(), strings.Join(columns, ","), strings.Join(sqls, ","), @@ -616,7 +616,7 @@ func (s *Do) createTable() *Do { } s.sql = fmt.Sprintf( - "CREATE TABLE \"%v\" (%v)", + "CREATE TABLE %v (%v)", s.tableName(), strings.Join(sqls, ","), ) @@ -625,7 +625,7 @@ func (s *Do) createTable() *Do { func (s *Do) dropTable() *Do { s.sql = fmt.Sprintf( - "DROP TABLE \"%v\"", + "DROP TABLE %v", s.tableName(), ) return s diff --git a/gorm_test.go b/gorm_test.go index 930602f8..1a11aa25 100644 --- a/gorm_test.go +++ b/gorm_test.go @@ -1099,4 +1099,6 @@ func TestForReadme(t *testing.T) { } db.Save(&user) + var users []User + db.Where("name in (?)", []string{"jinzhu", "jinzhu 2"}).Find(&users) }