Fix Join condition with DB

This commit is contained in:
Jinzhu 2021-09-28 22:37:15 +08:00
parent 002bf78ea7
commit c4a2e891da
1 changed files with 2 additions and 2 deletions

View File

@ -175,10 +175,10 @@ func (db *DB) Or(query interface{}, args ...interface{}) (tx *DB) {
func (db *DB) Joins(query string, args ...interface{}) (tx *DB) { func (db *DB) Joins(query string, args ...interface{}) (tx *DB) {
tx = db.getInstance() tx = db.getInstance()
if len(args) > 0 { if len(args) == 1 {
if db, ok := args[0].(*DB); ok { if db, ok := args[0].(*DB); ok {
if where, ok := db.Statement.Clauses["WHERE"].Expression.(clause.Where); 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 return
} }
} }