Skip to content

Commit

Permalink
One more fix on conflict detection
Browse files Browse the repository at this point in the history
  • Loading branch information
suprjinx committed Apr 12, 2024
1 parent 63d47b0 commit 3b74cc6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/api/mlflow/dao/repositories/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ func (r ParamRepository) CreateBatch(ctx context.Context, batchSize int, params
func findConflictingParams(tx *gorm.DB, params []models.Param) ([]paramConflict, error) {
var conflicts []paramConflict
placeholders, values := makeParamConflictPlaceholdersAndValues(params, tx.Dialector.Name())
nullSafeEquality := "<=>"
nullSafeEquality := "IS NOT"
if (tx.Dialector.Name() == postgres.Dialector{}.Name()) {
nullSafeEquality = "IS NOT DISTINCT FROM"
nullSafeEquality = "IS DISTINCT FROM"
}
sql := fmt.Sprintf(`WITH new(key, run_uuid, value_int, value_float, value_str) AS (%s)
SELECT current.run_uuid, current.key, CONCAT(current.value_int,
current.value_float, current.value_str) as old_value, CONCAT(new.value_int,
new.value_float, new.value_str) as new_value
FROM params AS current
INNER JOIN new USING (run_uuid, key)
WHERE NOT (new.value_int %s current.value_int)
OR NOT (new.value_float %s current.value_float)
OR NOT (new.value_str %s current.value_str)`,
WHERE (new.value_int %s current.value_int)
OR (new.value_float %s current.value_float)
OR (new.value_str %s current.value_str)`,
placeholders, nullSafeEquality, nullSafeEquality, nullSafeEquality)
if err := tx.Raw(sql, values...).
Find(&conflicts).Error; err != nil {
Expand Down

0 comments on commit 3b74cc6

Please sign in to comment.