forked from mirror/gorm
Get correct quoted table name
This commit is contained in:
parent
3c28ceea66
commit
cad0a42875
|
@ -151,7 +151,7 @@ func (s JoinTableHandler) JoinWith(db *DB, source interface{}) *DB {
|
||||||
var values []interface{}
|
var values []interface{}
|
||||||
if s.Source.ModelType == modelType {
|
if s.Source.ModelType == modelType {
|
||||||
for _, foreignKey := range s.Destination.ForeignKeys {
|
for _, foreignKey := range s.Destination.ForeignKeys {
|
||||||
destinationTableName := scope.New(reflect.New(s.Destination.ModelType).Interface()).QuotedTableName()
|
destinationTableName := db.NewScope(reflect.New(s.Destination.ModelType).Interface()).QuotedTableName()
|
||||||
joinConditions = append(joinConditions, fmt.Sprintf("%v.%v = %v.%v", quotedTable, scope.Quote(foreignKey.DBName), destinationTableName, scope.Quote(foreignKey.AssociationDBName)))
|
joinConditions = append(joinConditions, fmt.Sprintf("%v.%v = %v.%v", quotedTable, scope.Quote(foreignKey.DBName), destinationTableName, scope.Quote(foreignKey.AssociationDBName)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue