qb icon indicating copy to clipboard operation
qb copied to clipboard

`update` with `returning` does not create an output clause in sql server grammer

Open davidAtInleague opened this issue 2 years ago • 0 comments

getInstance("QueryBuilder@qb")
    .from("foo")
    .returning(["bar","baz"])
    .where("key", "=", "someValue")
    .update(values={freshValue: 42}, toSql=true);

produces

UPDATE [foo] SET [FRESHVALUE] = ? WHERE [key] = ?

but should be something like

UPDATE [foo] SET [FRESHVALUE] = ? OUTPUT INSERTED.[bar], INSERTED.[baz] WHERE [key] = ?

probably returning in an update context would need to accept something like

returning({inserted: ["bar","baz"], deleted: ["bar","baz"]})

since an UPDATE can output both the old and new values.

davidAtInleague avatar Mar 02 '22 15:03 davidAtInleague