dyedgreen / deno-sqlite

Deno SQLite module
https://deno.land/x/sqlite
MIT License
409 stars 36 forks source link

Filtering for NULL doesn't work #35

Closed timonson closed 4 years ago

timonson commented 4 years ago

The following example returns: Rows { _db: null, _id: -1, _done: true }

const results3 = (db.query(
  "SELECT Name, Composer FROM tracks WHERE Composer = NULL"
) as unknown) as any[]

You can find the sample db here: https://www.sqlitetutorial.net/sqlite-sample-database/

I will add a test for NULL tomorrow if this is desired.

dyedgreen commented 4 years ago

Thanks for raising the issue, I’ll have a look at this tomorrow.

The result you get looks a lot like the ‘Empty’ row constant, that you get when there are no rows to iterate over in the result. Maybe the query simply returns no results?

Could you specify the database/ provide a minimal sql snippet that creates the database you run this query against?

timonson commented 4 years ago

Hi @dyedgreen, the SQLite db is here: https://cdn.sqlitetutorial.net/wp-content/uploads/2018/03/chinook.zip

You were right, it returns no results because I made an incorrect query. The correct query would be: "SELECT Name, Composer FROM tracks WHERE Composer IS NULL"

Sorry for the inconvenience! I will close this now.

dyedgreen commented 4 years ago

Ah, no worries! Thanks for reaching out either way, happy the problem could be resolved quickly! 😄