jawj / zapatos

Zero-abstraction Postgres for TypeScript: a non-ORM database library
https://jawj.github.io/zapatos/
Other
1.3k stars 46 forks source link

No error is thrown if selectExactlyOne selects 0 rows when used in a lateral #129

Open tetchel opened 2 years ago

tetchel commented 2 years ago

I've created a repository with a repro and details here: https://github.com/tetchel/zap-lateral-bug

jawj commented 2 years ago

Hmm. I guess the idea of selectExactlyOne is that you use it when you absolutely know that there is one matching row — e.g. because you're joining on a NOT NULL foreign key.

That said, you're right that this is unexpected and inconsistent behaviour, and that qualifies it as a great big bug. I'll see if I can fix it!

purge commented 2 years ago

Ha, I just experienced this! you think you absolutely know there's one matching row but RLS makes that uncertain :)

tetchel commented 2 years ago

yeah, for us we'd removed a NOT NULL from a FK column and did not think to update all the laterals using that column as a join.