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

Problems with booleans #45

Closed
rulatir opened this issue Apr 12, 2016 · 3 comments
Closed

Problems with booleans #45

rulatir opened this issue Apr 12, 2016 · 3 comments

Comments

@rulatir
Copy link

rulatir commented Apr 12, 2016

At line 421:

params.push((v === null || v === void 0 || t === 'number' || t === 'string' ? v : v instanceof Blob ? v.valueOf() : v.toString()));

If it is neither null nor 0 nor number nor string but boolean, then the v instanceof Blob condition is evaluated. There is no Blob in React Native (at least on Android), so this throws, but the exception is caught somewhere down the stack and converted to console warning (took a while to notice!) w/o fixing the problem.

Shimming Blob = function(){} seems to quickfix the exception but doesn't really help handle booleans. WebSQL is supposed to be able to store booleans but the code above will probably end up storing strings "true" and "false", which will both evaluate to true to an application that expects actual booleans returned from the database.

@andpor
Copy link
Owner

andpor commented Apr 13, 2016

@rulatir I added a check for boolean but i am not sure if this is handled properly at the sqlite level. From what I see there is no boolean type column...

Anyway ... try it and let me know what you find...

@rulatir
Copy link
Author

rulatir commented Apr 13, 2016

I don't think there's anything left to be done with Blob other than an existence check to avoid exception. If there is no Blob on the platform then the app won't be storing Blobs, period.

@andpor
Copy link
Owner

andpor commented Apr 13, 2016

SQLite does not distinguish booleans from ints. So you can just use bind_int. The only real storage classes are NULL, INTEGER, REAL, TEXT, and BLOB.

So I suppose the option would be to convert a JS boolean type to int and use 0/1 in the database...you would get 0/1 in result set as well...

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

No branches or pull requests

2 participants