From af97f92df5646866994d01bd635b59d1f44f9e11 Mon Sep 17 00:00:00 2001 From: Aaron Lindsay Date: Sat, 9 Dec 2017 05:47:25 -0500 Subject: [PATCH] db: Paper over MySQL returning count=0 for unchanged updates --- internal/store/db/tx.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/store/db/tx.go b/internal/store/db/tx.go index 5187201..c899dc0 100644 --- a/internal/store/db/tx.go +++ b/internal/store/db/tx.go @@ -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) {