erlang-sqlite3 icon indicating copy to clipboard operation
erlang-sqlite3 copied to clipboard

Where col = null

Open lightuponcloud opened this issue 2 years ago • 3 comments

Hello

Sqlite3 expects the following syntax when when checking for NULL:

SELECT 1 FROM items WHERE col is NULL;

The query where "col = NULL" ( with equal sign ) is used, returns no records.

lightuponcloud avatar Dec 01 '22 14:12 lightuponcloud

Hello,

Do we have query like that somewhere, or are you asking about adding code that will replace queries like this with is null?

prefiks avatar Dec 01 '22 15:12 prefiks

For example:

sqlite3_lib:read_sql(Tbl, Key, Value) -> ["SELECT * FROM ", to_iolist(Tbl), " WHERE ", to_iolist(Key), " = ", value_to_sql(Value), ";"].

if Value is null, an equal sign will be used in SQL query, when it seems sqlite3 expects "is" operator.

lightuponcloud avatar Dec 01 '22 15:12 lightuponcloud

Ok, i see. Those functions are just for convenience, we expect that for more complex stuff you will need to use sql directly, but i may be able to add handling for this case.

prefiks avatar Dec 01 '22 15:12 prefiks