beam icon indicating copy to clipboard operation
beam copied to clipboard

updateReturning surprising behavior when assignments are empty

Open roberth opened this issue 4 years ago • 1 comments

When using updateReturning as an optimized of update plus select, with a variable set of assignments, it's surprising that no rows are returned when the assignments are empty.

The behavior does make sense for use cases where you're only interested in the changes, so it seems like beam should have two functions. Perhaps updateReturningChanged and updateReturningMatched. The latter would perform a SELECT when the assignments are empty, because UPDATE table SET WHERE ... isn't valid syntax.

roberth avatar Mar 10 '21 13:03 roberth

Agreed that this behavior is weird, especially because SQL doesn't allow updates with no assignments, so we have total freedom to make the behavior whatever we want in that case. If it weren't for compatibility, I think I'd like to just make updateReturning do the SELECT in that case.

kmicklas avatar Mar 14 '21 16:03 kmicklas