I made a silly mistake while writing a PostgreSQL request. The syntax seems to be completely wrong, however it still half work.
I have this table (subscriber):
id - device_id - invert
1 'abcd' true
2 'abcd' true
There are other rows but those are the only one concerned (with the same device_id
)
And I made the request :
UPDATE subscriber
SET invert = false
WHERE device_id = (SELECT device_id WHERE id = 1)
RETURNING *;
I forgot the FROM
clause of the sub-select. The sub-select on it's own crash as expected (device_id does not exist
). However, the full request compute, and does update and return one of the row (the one with id = 1
). The correct request should update and return both rows.
Why? Is it some kind of bug? Or does the sub-select behave differently from a select?