Skip to content

Commit

Permalink
Combine lines
Browse files Browse the repository at this point in the history
  • Loading branch information
danafallon committed Jul 19, 2024
1 parent 18d7f81 commit 1163c02
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions clients/mssql/dialect/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ WHERE %s IS NULL;`,
),
fmt.Sprintf(`
UPDATE %s SET %s
FROM %s AS %s
LEFT JOIN %s AS %s ON %s%s
FROM %s AS %s LEFT JOIN %s AS %s ON %s%s
WHERE COALESCE(%s, 0) = 0;`,
// UPDATE table set [all columns]
constants.TargetAlias, sql.BuildColumnsUpdateFragment(cols, constants.StagingAlias, constants.TargetAlias, md),
Expand All @@ -241,8 +240,7 @@ WHERE COALESCE(%s, 0) = 0;`,
),
fmt.Sprintf(`
UPDATE %s SET %s
FROM %s AS %s
LEFT JOIN %s AS %s ON %s%s
FROM %s AS %s LEFT JOIN %s AS %s ON %s%s
WHERE COALESCE(%s, 0) = 1;`,
// UPDATE table SET __artie_delete = stg.__artie_delete
constants.TargetAlias, sql.BuildColumnsUpdateFragment([]columns.Column{columns.NewColumn(constants.DeleteColumnMarker, typing.Boolean)}, constants.StagingAlias, constants.TargetAlias, md),
Expand Down
6 changes: 2 additions & 4 deletions clients/mssql/dialect/dialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,11 @@ LEFT JOIN database.schema.table AS tgt ON tgt."id" = stg."id"
WHERE tgt."id" IS NULL;`, queries[0])
assert.Equal(t, `
UPDATE tgt SET "id"=stg."id","bar"=stg."bar","updated_at"=stg."updated_at","start"=stg."start","__artie_delete"=stg."__artie_delete"
FROM {SUB_QUERY} AS stg
LEFT JOIN database.schema.table AS tgt ON tgt."id" = stg."id"
FROM {SUB_QUERY} AS stg LEFT JOIN database.schema.table AS tgt ON tgt."id" = stg."id"
WHERE COALESCE(stg."__artie_only_set_delete", 0) = 0;`, queries[1])
assert.Equal(t, `
UPDATE tgt SET "__artie_delete"=stg."__artie_delete"
FROM {SUB_QUERY} AS stg
LEFT JOIN database.schema.table AS tgt ON tgt."id" = stg."id"
FROM {SUB_QUERY} AS stg LEFT JOIN database.schema.table AS tgt ON tgt."id" = stg."id"
WHERE COALESCE(stg."__artie_only_set_delete", 0) = 1;`, queries[2])
}
}

0 comments on commit 1163c02

Please sign in to comment.