Skip to content

Commit

Permalink
changed dropTableImpl to use the transaction if it's there
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Culbreth committed Apr 11, 2014
1 parent 25cbcab commit 4fc09f6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions gorp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 4fc09f6

Please sign in to comment.