Open systemmonkey42 opened 5 months ago
Test case for issue go-gorm/gorm#7076
Gorm "Scopes" don't work as advertised when used as a join condition.
In this particular case, the following diff naively resolves the issue
diff --git chainable_api.go chainable_api.go index e6c90cefe268..84c77c958634 100644 --- chainable_api.go +++ chainable_api.go @@ -257,6 +257,7 @@ func joins(db *DB, joinType clause.JoinType, query string, args ...interface{}) Name: query, Conds: args, Selects: db.Statement.Selects, Omits: db.Statement.Omits, JoinType: joinType, } + db = db.executeScopes() if where, ok := db.Statement.Clauses["WHERE"].Expression.(clause.Where); ok { j.On = &where }
Explain your user case and expected results
Test case for issue go-gorm/gorm#7076
Gorm "Scopes" don't work as advertised when used as a join condition.
In this particular case, the following diff naively resolves the issue