From 00664acbcd3d7d09f7f086366754afa2c32beac5 Mon Sep 17 00:00:00 2001 From: Schparky <3172830+Schparky@users.noreply.github.com> Date: Fri, 28 Jan 2022 16:42:26 -0700 Subject: [PATCH 1/3] log SQL for association query --- executors.go | 1 + 1 file changed, 1 insertion(+) diff --git a/executors.go b/executors.go index 04478f66..73f2ac12 100644 --- a/executors.go +++ b/executors.go @@ -297,6 +297,7 @@ func (c *Connection) Create(model interface{}, excludeColumns ...string) error { for index := range stms { statements := stms[index].Statements() for _, stm := range statements { + log(logging.SQL, stm.Statement, stm.Args...) if c.TX != nil { _, err := c.TX.Exec(c.Dialect.TranslateSQL(stm.Statement), stm.Args...) if err != nil { From 091f062eb3bb102813feb574d38550de552a1544 Mon Sep 17 00:00:00 2001 From: Schparky <3172830+Schparky@users.noreply.github.com> Date: Fri, 28 Jan 2022 16:47:45 -0700 Subject: [PATCH 2/3] log SQL for association query --- executors.go | 1 + 1 file changed, 1 insertion(+) diff --git a/executors.go b/executors.go index 04478f66..73f2ac12 100644 --- a/executors.go +++ b/executors.go @@ -297,6 +297,7 @@ func (c *Connection) Create(model interface{}, excludeColumns ...string) error { for index := range stms { statements := stms[index].Statements() for _, stm := range statements { + log(logging.SQL, stm.Statement, stm.Args...) if c.TX != nil { _, err := c.TX.Exec(c.Dialect.TranslateSQL(stm.Statement), stm.Args...) if err != nil { From 8bc279dcf79e8ddf80380b0f565bc37ec721454a Mon Sep 17 00:00:00 2001 From: Schparky <3172830+Schparky@users.noreply.github.com> Date: Sat, 17 Sep 2022 20:34:30 +0800 Subject: [PATCH 3/3] use higher-level log-enabled functions instead of calling log directly --- executors.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/executors.go b/executors.go index 73f2ac12..c828162e 100644 --- a/executors.go +++ b/executors.go @@ -286,7 +286,7 @@ func (c *Connection) Create(model interface{}, excludeColumns ...string) error { } stm := after[index].AfterProcess() if c.TX != nil && !stm.Empty() { - _, err := c.TX.Exec(c.Dialect.TranslateSQL(stm.Statement), stm.Args...) + err := c.RawQuery(c.Dialect.TranslateSQL(stm.Statement), stm.Args...).Exec() if err != nil { return err } @@ -297,15 +297,7 @@ func (c *Connection) Create(model interface{}, excludeColumns ...string) error { for index := range stms { statements := stms[index].Statements() for _, stm := range statements { - log(logging.SQL, stm.Statement, stm.Args...) - if c.TX != nil { - _, err := c.TX.Exec(c.Dialect.TranslateSQL(stm.Statement), stm.Args...) - if err != nil { - return err - } - continue - } - _, err = c.Store.Exec(c.Dialect.TranslateSQL(stm.Statement), stm.Args...) + err := c.RawQuery(c.Dialect.TranslateSQL(stm.Statement), stm.Args...).Exec() if err != nil { return err }