fix: #2549 Check the DeleteAt field of the join table
This commit is contained in:
parent
836fb2c19d
commit
47150353e6
@ -175,6 +175,12 @@ func (s JoinTableHandler) JoinWith(handler JoinTableHandlerInterface, db *DB, so
|
|||||||
joinConditions = append(joinConditions, fmt.Sprintf("%v.%v = %v.%v", quotedTableName, scope.Quote(foreignKey.DBName), destinationTableName, scope.Quote(foreignKey.AssociationDBName)))
|
joinConditions = append(joinConditions, fmt.Sprintf("%v.%v = %v.%v", quotedTableName, scope.Quote(foreignKey.DBName), destinationTableName, scope.Quote(foreignKey.AssociationDBName)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deletedAtField, hasDeletedAtField := scope.FieldByName("DeletedAt")
|
||||||
|
if !scope.Search.Unscoped && hasDeletedAtField {
|
||||||
|
sql := fmt.Sprintf("%v.%v IS NULL", quotedTableName, scope.Quote(deletedAtField.DBName))
|
||||||
|
joinConditions = append(joinConditions, sql)
|
||||||
|
}
|
||||||
|
|
||||||
var foreignDBNames []string
|
var foreignDBNames []string
|
||||||
var foreignFieldNames []string
|
var foreignFieldNames []string
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user