diff --git a/association.go b/association.go index 7adb8c91..d93ff8ca 100644 --- a/association.go +++ b/association.go @@ -470,7 +470,7 @@ func (association *Association) buildCondition() *DB { tx.Clauses(clause.Expr{SQL: strings.Replace(joinStmt.SQL.String(), "WHERE ", "", 1), Vars: joinStmt.Vars}) } - tx.Clauses(clause.From{Joins: []clause.Join{{ + tx = tx.Session(&Session{QueryFields: true}).Clauses(clause.From{Joins: []clause.Join{{ Table: clause.Table{Name: association.Relationship.JoinTable.Table}, ON: clause.Where{Exprs: queryConds}, }}}) diff --git a/tests/go.mod b/tests/go.mod index 03283a53..f6912a0f 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -8,10 +8,10 @@ require ( github.com/lib/pq v1.6.0 github.com/stretchr/testify v1.5.1 gorm.io/driver/mysql v1.0.3 - gorm.io/driver/postgres v1.0.5 + gorm.io/driver/postgres v1.0.6 gorm.io/driver/sqlite v1.1.4 gorm.io/driver/sqlserver v1.0.5 - gorm.io/gorm v1.20.7 + gorm.io/gorm v1.20.8 ) replace gorm.io/gorm => ../