The Wayback Machine - https://web.archive.org/web/20210124105409/https://github.com/sql-js/sql.js/issues/296
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning zero from user-defined function treated as returning null #296

Open
AnyhowStep opened this issue Sep 20, 2019 · 4 comments
Open

Returning zero from user-defined function treated as returning null #296

AnyhowStep opened this issue Sep 20, 2019 · 4 comments

Comments

@AnyhowStep
Copy link

@AnyhowStep AnyhowStep commented Sep 20, 2019

db = new Database();
db.create_function(
    "returnZero",
    () => 0
);
db.exec("SELECT returnZero(), 0");

Expected:

returnZero() 0
0 0

Actual:

returnZero() 0
null 0
@AnyhowStep
Copy link
Author

@AnyhowStep AnyhowStep commented Sep 20, 2019

Tracked the bug down to this line of code.
image

@AnyhowStep
Copy link
Author

@AnyhowStep AnyhowStep commented Sep 20, 2019

!0 is true.

So, it thinks 0 is null

@AnyhowStep
Copy link
Author

@AnyhowStep AnyhowStep commented Sep 20, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant