From a1e492244f157087ad10d846bf77309afefe275d Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Thu, 6 Aug 2020 16:25:26 +0800 Subject: [PATCH] Use table expr when inserting table --- callbacks/create.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/callbacks/create.go b/callbacks/create.go index b41a3ef2..3a414dd7 100644 --- a/callbacks/create.go +++ b/callbacks/create.go @@ -43,9 +43,7 @@ func Create(config *Config) func(db *gorm.DB) { if db.Statement.SQL.String() == "" { db.Statement.SQL.Grow(180) - db.Statement.AddClauseIfNotExists(clause.Insert{ - Table: clause.Table{Name: db.Statement.Table}, - }) + db.Statement.AddClauseIfNotExists(clause.Insert{}) db.Statement.AddClause(ConvertToCreateValues(db.Statement)) db.Statement.Build("INSERT", "VALUES", "ON CONFLICT") @@ -105,9 +103,7 @@ func CreateWithReturning(db *gorm.DB) { } if db.Statement.SQL.String() == "" { - db.Statement.AddClauseIfNotExists(clause.Insert{ - Table: clause.Table{Name: db.Statement.Table}, - }) + db.Statement.AddClauseIfNotExists(clause.Insert{}) db.Statement.AddClause(ConvertToCreateValues(db.Statement)) db.Statement.Build("INSERT", "VALUES", "ON CONFLICT")