forked from mirror/gorm
Don't quote table names
This commit is contained in:
parent
63a9e5e3ae
commit
0c4e43cd7a
|
@ -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
|
||||
|
|
6
do.go
6
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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue