GORM Playground Link
https://github.com/go-gorm/playground/pull/665
Description
const (
skema = "my_schema"
)
...
nameStrategy := schema.NamingStrategy{
TablePrefix: skema + "." + "custom__",
}
...
db, err = gorm.Open(sqlserver.Open(dbDSN), &gorm.Config{
NamingStrategy: nameStrategy,
})
db.Exec("CREATE SCHEMA my_schema")
user := User{
Model: gorm.Model{
ID: 1,
},
Name: "jinzhu",
}
DB.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "id"}},
UpdateAll: true,
}).Create(&user)
When try to upsert to sqlserver with schema, the script generated is not correct to sqlserver.
generated
MERGE INTO "custom__users" USING (VALUES('2023-11-24 10:17:52.412','2023-11-24 10:17:52.412',NULL,'jinzhu',0,NULL,NULL,NULL,0,1)) AS excluded ("created_at","updated_at","deleted_at","name","age","birthday","company_id","manager_id","active","id") ON "custom__users"."id" = "excluded"."id" WHEN MATCHED THEN UPDATE SET "updated_at"='2023-11-24 10:17:52.412',"deleted_at"="excluded"."deleted_at","name"="excluded"."name","age"="excluded"."age","birthday"="excluded"."birthday","company_id"="excluded"."company_id","manager_id"="excluded"."manager_id","active"="excluded"."active" WHEN NOT MATCHED THEN INSERT ("created_at","updated_at","deleted_at","name","age","birthday","company_id","manager_id","active") VALUES ("excluded"."created_at","excluded"."updated_at","excluded"."deleted_at","excluded"."name","excluded"."age","excluded"."birthday","excluded"."company_id","excluded"."manager_id","excluded"."active") OUTPUT INSERTED."id";
should be
MERGE INTO "my_schema"."custom__users" USING ...
Comment From: stonefiled
Issue still exists. Why hasn't this been merged?