Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
Andrew Thornton 2023-03-13 20:24:07 +00:00
parent e88ca1d017
commit 5a188e58d1
No known key found for this signature in database
GPG Key ID: 3CDE74631F13A748
1 changed files with 2 additions and 2 deletions

View File

@ -121,7 +121,7 @@ func (session *Session) upsertMap(doUpdate bool, columns []string, args []interf
if err != nil { if err != nil {
return 0, err return 0, err
} }
if numberOfUniqueConstraints > 1 { if doUpdate && numberOfUniqueConstraints > 1 {
return 0, fmt.Errorf("cannot upsert if there is more than one unique constraint") return 0, fmt.Errorf("cannot upsert if there is more than one unique constraint")
} }
@ -176,7 +176,7 @@ func (session *Session) upsertStruct(doUpdate bool, bean interface{}) (int64, er
if err != nil { if err != nil {
return 0, err return 0, err
} }
if numberOfUniqueConstraints > 1 { if doUpdate && numberOfUniqueConstraints > 1 {
return 0, fmt.Errorf("cannot upsert if there is more than one unique constraint") return 0, fmt.Errorf("cannot upsert if there is more than one unique constraint")
} }