diff --git a/callback_create.go b/callback_create.go index 7ad40f4b..2f641b3d 100644 --- a/callback_create.go +++ b/callback_create.go @@ -35,13 +35,13 @@ func Create(scope *Scope) { if len(columns) == 0 { scope.Raw(fmt.Sprintf("INSERT INTO %v DEFAULT VALUES %v", - scope.Quote(scope.TableName()), + scope.TableName(), scope.Dialect().ReturningStr(scope.PrimaryKey()), )) } else { scope.Raw(fmt.Sprintf( "INSERT INTO %v (%v) VALUES (%v) %v", - scope.Quote(scope.TableName()), + scope.TableName(), strings.Join(columns, ","), strings.Join(sqls, ","), scope.Dialect().ReturningStr(scope.PrimaryKey()), diff --git a/callback_delete.go b/callback_delete.go index 9539b4ca..3bf5b7b0 100644 --- a/callback_delete.go +++ b/callback_delete.go @@ -14,12 +14,12 @@ func Delete(scope *Scope) { if !scope.Search.Unscope && scope.HasColumn("DeletedAt") { scope.Raw( fmt.Sprintf("UPDATE %v SET deleted_at=%v %v", - scope.Quote(scope.TableName()), + scope.TableName(), scope.AddToVars(time.Now()), scope.CombinedConditionSql(), )) } else { - scope.Raw(fmt.Sprintf("DELETE FROM %v %v", scope.Quote(scope.TableName()), scope.CombinedConditionSql())) + scope.Raw(fmt.Sprintf("DELETE FROM %v %v", scope.TableName(), scope.CombinedConditionSql())) } scope.Exec() diff --git a/callback_update.go b/callback_update.go index 138953a0..095bbf48 100644 --- a/callback_update.go +++ b/callback_update.go @@ -59,7 +59,7 @@ func Update(scope *Scope) { scope.Raw(fmt.Sprintf( "UPDATE %v SET %v %v", - scope.Quote(scope.TableName()), + scope.TableName(), strings.Join(sqls, ", "), scope.CombinedConditionSql(), )) diff --git a/scope_private.go b/scope_private.go index 49c43d43..232e6150 100644 --- a/scope_private.go +++ b/scope_private.go @@ -237,7 +237,7 @@ func (scope *Scope) prepareQuerySql() { if scope.Search.Raw { scope.Raw(strings.TrimLeft(scope.CombinedConditionSql(), "WHERE ")) } else { - scope.Raw(fmt.Sprintf("SELECT %v FROM %v %v", scope.selectSql(), scope.Quote(scope.TableName()), scope.CombinedConditionSql())) + scope.Raw(fmt.Sprintf("SELECT %v FROM %v %v", scope.selectSql(), scope.TableName(), scope.CombinedConditionSql())) } return } @@ -414,21 +414,21 @@ func (scope *Scope) createTable() *Scope { sqls = append(sqls, scope.Quote(field.DBName)+" "+field.SqlTag) } } - scope.Raw(fmt.Sprintf("CREATE TABLE %v (%v)", scope.Quote(scope.TableName()), strings.Join(sqls, ","))).Exec() + scope.Raw(fmt.Sprintf("CREATE TABLE %v (%v)", scope.TableName(), strings.Join(sqls, ","))).Exec() return scope } func (scope *Scope) dropTable() *Scope { - scope.Raw(fmt.Sprintf("DROP TABLE %v", scope.Quote(scope.TableName()))).Exec() + scope.Raw(fmt.Sprintf("DROP TABLE %v", scope.TableName())).Exec() return scope } func (scope *Scope) modifyColumn(column string, typ string) { - scope.Raw(fmt.Sprintf("ALTER TABLE %v MODIFY %v %v", scope.Quote(scope.TableName()), scope.Quote(column), typ)).Exec() + scope.Raw(fmt.Sprintf("ALTER TABLE %v MODIFY %v %v", scope.TableName(), scope.Quote(column), typ)).Exec() } func (scope *Scope) dropColumn(column string) { - scope.Raw(fmt.Sprintf("ALTER TABLE %v DROP COLUMN %v", scope.Quote(scope.TableName()), scope.Quote(column))).Exec() + scope.Raw(fmt.Sprintf("ALTER TABLE %v DROP COLUMN %v", scope.TableName(), scope.Quote(column))).Exec() } func (scope *Scope) addIndex(unique bool, indexName string, column ...string) { @@ -442,11 +442,11 @@ func (scope *Scope) addIndex(unique bool, indexName string, column ...string) { sqlCreate = "CREATE UNIQUE INDEX" } - scope.Raw(fmt.Sprintf("%s %v ON %v(%v);", sqlCreate, indexName, scope.Quote(scope.TableName()), strings.Join(columns, ", "))).Exec() + scope.Raw(fmt.Sprintf("%s %v ON %v(%v);", sqlCreate, indexName, scope.QuotedTableName(), strings.Join(columns, ", "))).Exec() } func (scope *Scope) removeIndex(indexName string) { - scope.Raw(fmt.Sprintf("DROP INDEX %v ON %v", indexName, scope.Quote(scope.TableName()))).Exec() + scope.Raw(fmt.Sprintf("DROP INDEX %v ON %v", indexName, scope.TableName())).Exec() } func (scope *Scope) autoMigrate() *Scope { @@ -456,7 +456,7 @@ func (scope *Scope) autoMigrate() *Scope { for _, field := range scope.Fields() { if !scope.Dialect().HasColumn(scope, scope.TableName(), field.DBName) { if len(field.SqlTag) > 0 && !field.IsIgnored { - scope.Raw(fmt.Sprintf("ALTER TABLE %v ADD %v %v;", scope.Quote(scope.TableName()), field.DBName, field.SqlTag)).Exec() + scope.Raw(fmt.Sprintf("ALTER TABLE %v ADD %v %v;", scope.TableName(), field.DBName, field.SqlTag)).Exec() } } }