Avoid use of IS operator in SQL queries #120

Closed
opened 7 years ago by jking · 0 comments
jking commented 7 years ago
Owner

I was under the mistaken impression that SQLite's null-safe IS comparison operator was portable; in fact it is not at all so.

In order to keep queries portable, all use of IS needs to be replaced with =, and all references to folders need to be wrapped with COALESCE(). For example:

SELECT * from arsse_folders where coalesce(parent,0) = coalesce(?,0);

Bound parameters could also use our strict int type to cast nulls to zero instead of wrapping with COALESCE().

I was under the mistaken impression that SQLite's null-safe `IS` comparison operator was portable; in fact it is not at all so. In order to keep queries portable, all use of `IS` needs to be replaced with `=`, and all references to folders need to be wrapped with `COALESCE()`. For example: ```sql SELECT * from arsse_folders where coalesce(parent,0) = coalesce(?,0); ``` Bound parameters could also use our `strict int` type to cast nulls to zero instead of wrapping with `COALESCE()`.
jking added the
bug
internals
labels 7 years ago
jking added this to the Future milestone 7 years ago
jking changed title from Use of IS operator in SQL queries to Avoid use of IS operator in SQL queries 7 years ago
jking modified the milestone from Future to 0.2.1 6 years ago
jking closed this issue 6 years ago
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.