From 5a188e58d16a6c819f5c4e918b48c980a4ba9db0 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Mon, 13 Mar 2023 20:24:07 +0000 Subject: [PATCH] oops Signed-off-by: Andrew Thornton --- session_upsert.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/session_upsert.go b/session_upsert.go index 9b3595e2..784703ba 100644 --- a/session_upsert.go +++ b/session_upsert.go @@ -121,7 +121,7 @@ func (session *Session) upsertMap(doUpdate bool, columns []string, args []interf if err != nil { return 0, err } - if numberOfUniqueConstraints > 1 { + if doUpdate && numberOfUniqueConstraints > 1 { 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 { return 0, err } - if numberOfUniqueConstraints > 1 { + if doUpdate && numberOfUniqueConstraints > 1 { return 0, fmt.Errorf("cannot upsert if there is more than one unique constraint") }