From 7ebb320f3ec98333603e213bcda6fb0d13a2c412 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sun, 10 Jan 2021 14:58:54 +0800 Subject: [PATCH] Allow customize join table's table in callback --- callbacks/preload.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callbacks/preload.go b/callbacks/preload.go index 682427c9..5c56d851 100644 --- a/callbacks/preload.go +++ b/callbacks/preload.go @@ -49,7 +49,7 @@ func preload(db *gorm.DB, rels []*schema.Relationship, conds []interface{}) { } joinResults := rel.JoinTable.MakeSlice().Elem() - column, values := schema.ToQueryValues(rel.JoinTable.Table, joinForeignKeys, joinForeignValues) + column, values := schema.ToQueryValues(clause.CurrentTable, joinForeignKeys, joinForeignValues) db.AddError(tx.Where(clause.IN{Column: column, Values: values}).Find(joinResults.Addr().Interface()).Error) // convert join identity map to relation identity map