From c4a2e891daee9fa5ba4305b3594d2e155a17a082 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Tue, 28 Sep 2021 22:37:15 +0800 Subject: [PATCH] Fix Join condition with DB --- chainable_api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chainable_api.go b/chainable_api.go index 23e60110..173479d3 100644 --- a/chainable_api.go +++ b/chainable_api.go @@ -175,10 +175,10 @@ func (db *DB) Or(query interface{}, args ...interface{}) (tx *DB) { func (db *DB) Joins(query string, args ...interface{}) (tx *DB) { tx = db.getInstance() - if len(args) > 0 { + if len(args) == 1 { if db, ok := args[0].(*DB); ok { if where, ok := db.Statement.Clauses["WHERE"].Expression.(clause.Where); ok { - tx.Statement.Joins = append(tx.Statement.Joins, join{Name: query, Conds: args[1:], On: &where}) + tx.Statement.Joins = append(tx.Statement.Joins, join{Name: query, Conds: args, On: &where}) return } }