From 00b252559f73dea64fabd6b80a2212f821383a93 Mon Sep 17 00:00:00 2001 From: liamrfell <42047511+liamrfell@users.noreply.github.com> Date: Mon, 7 Jun 2021 03:39:24 +0100 Subject: [PATCH] Fix: FirstOrCreate slice out of bounds error when using 'Assigns' (#4436) Co-authored-by: Liam Fell --- finisher_api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/finisher_api.go b/finisher_api.go index c3941784..7b8afabd 100644 --- a/finisher_api.go +++ b/finisher_api.go @@ -304,7 +304,7 @@ func (db *DB) FirstOrCreate(dest interface{}, conds ...interface{}) (tx *DB) { return tx.Create(dest) } else if len(db.Statement.assigns) > 0 { - exprs := tx.Statement.BuildCondition(tx.Statement.assigns[0], tx.Statement.assigns[1:]...) + exprs := tx.Statement.BuildCondition(db.Statement.assigns[0], db.Statement.assigns[1:]...) assigns := map[string]interface{}{} for _, expr := range exprs { if eq, ok := expr.(clause.Eq); ok {