mirror of
https://github.com/aclindsa/moneygo.git
synced 2024-12-25 23:23:21 -05:00
db: Paper over MySQL returning count=0 for unchanged updates
This commit is contained in:
parent
da7e025509
commit
af97f92df5
@ -41,7 +41,20 @@ func (tx *Tx) Insert(list ...interface{}) error {
|
||||
}
|
||||
|
||||
func (tx *Tx) Update(list ...interface{}) (int64, error) {
|
||||
return tx.Tx.Update(list...)
|
||||
count, err := tx.Tx.Update(list...)
|
||||
if count == 0 {
|
||||
switch tx.Dialect.(type) {
|
||||
case gorp.MySQLDialect:
|
||||
// Always return 1 for 0 if we're using MySQL because it returns
|
||||
// count=0 if the row data was unchanged, even if the row existed
|
||||
|
||||
// TODO Find another way to fix this without risking ignoring
|
||||
// errors
|
||||
|
||||
count = 1
|
||||
}
|
||||
}
|
||||
return count, err
|
||||
}
|
||||
|
||||
func (tx *Tx) Delete(list ...interface{}) (int64, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user