qb
qb copied to clipboard
Upsert deleteUnmatched Should allow expresssion
The deleteUnmatched
argument in the upsert
function is currently too loose, as the result is a deletion of all rows in the database that don't match the source. Its current implementation is an atomic operation on the entire table.
It should be updated to allow an expression to restrict what gets deleted.
Example:
WHEN NOT MATCHED BY SOURCE AND qb_target.foo = 'bar' AND qb_target.active = 1 THEN DELETE
Suggest that the right hand side should allow an expression. Of note is the fact that qb_src
cannot be referenced in the WHEN NOT MATCHED BY SOURCE
clause.