sql.js
sql.js copied to clipboard
Returning zero from user-defined function treated as returning null
db = new Database();
db.create_function(
"returnZero",
() => 0
);
db.exec("SELECT returnZero(), 0");
Expected:
| returnZero() | 0 |
|---|---|
| 0 | 0 |
Actual:
| returnZero() | 0 |
|---|---|
| null | 0 |
Tracked the bug down to this line of code.

!0 is true.
So, it thinks 0 is null
https://github.com/kripken/sql.js/blob/master/dist/sql-wasm-debug.js#L764-L767
https://github.com/kripken/sql.js/blob/master/src/api.coffee#L484-L495
Seems like it was fixed recently, but no npm package was published, and the dist was not updated.