From 4fc09f6483481da40023f1796fd25dc5dd15fe7b Mon Sep 17 00:00:00 2001 From: Matt Culbreth Date: Fri, 11 Apr 2014 09:18:40 -0400 Subject: [PATCH] changed dropTableImpl to use the transaction if it's there --- gorp.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gorp.go b/gorp.go index 492e203b..d705f589 100644 --- a/gorp.go +++ b/gorp.go @@ -817,11 +817,9 @@ func (m *DbMap) createTables(ifNotExists bool) error { // use the transaction if it's there. otherwise, use the db connection. if m.Tx != nil { - fmt.Println("Using the Transaction") _, err = m.Tx.Exec(s.String()) } else { - fmt.Println("Using the database") _, err = m.Exec(s.String()) } @@ -886,7 +884,14 @@ func (m *DbMap) dropTableImpl(table *TableMap, addIfExists bool) (err error) { if addIfExists { ifExists = " if exists" } - _, err = m.Exec(fmt.Sprintf("drop table%s %s;", ifExists, m.Dialect.QuotedTableForQuery(table.SchemaName, table.TableName))) + + // use the transaction if it's there. otherwise, use the db connection. + if m.Tx != nil { + _, err = m.Tx.Exec(fmt.Sprintf("drop table%s %s;", ifExists, m.Dialect.QuotedTableForQuery(table.SchemaName, table.TableName))) + } else { + _, err = m.Exec(fmt.Sprintf("drop table%s %s;", ifExists, m.Dialect.QuotedTableForQuery(table.SchemaName, table.TableName))) + } + return err }