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

Cordova SQLite adapter not able to query select or delete by parameter array #94

Closed
ingljo opened this issue Nov 15, 2018 · 6 comments

Comments

Projects
None yet
3 participants
@ingljo
Copy link

commented Nov 15, 2018

Affected versions
NanoSQL version: 1.7.9
cordova-plugin-nano-sqlite version: 1.5.0

Describe the bug
When I use query ('delete' or 'select') with array paramterer in where clause (['id', '=', id]), I get 0 rows affected.
It works on IndexDB adapter in browser, but not on Cordova SQLite adapter on Android and iPhone.

Code that does not work on SQLite, but works with IndexDb Adapter:
nSQL().table('todo').query('delete').where(['id', '=', id]).exec();

Workaround that works on SQLite, but performance might not be as good?
nSQL().table('todo').query('delete').where((x) => x.id === id).exec();

Example
Full sample with Ionic v4 app using cordova plugin:
https://github.com/ingljo/nano-sql-test/blob/master/src/app/home/home.page.ts

Expected behavior
1 row should be affected when deleted.
Records should be returned when selected.

Additional info
It works as expected when using model with type int and ai:
{ key: 'id', type: 'int', props: ['ai', 'pk'] }

@ClickSimply

This comment has been minimized.

Copy link
Owner

commented Dec 7, 2018

It looks like there's an issue with integer primary keys being selected. I suspect it has something to do with SQLite messing with the primary key column as it gets inserted.

I'm going to need to modify all the SQLite plugins (Cordova/WebSQL/SQLite3) to treat the integer primary keys differently.

In the meantime if you switch to UUIDs the queries should work again as expected.

@ClickSimply ClickSimply added the bug label Dec 7, 2018

@ClickSimply

This comment has been minimized.

Copy link
Owner

commented Dec 16, 2018

This should be resolved as of NanoSQL v1.8.0 and Cordova/SQLite3 adapters v1.6.0. You may need to export your databases and reimport them if you were using a numerical primary key, the issue was due to a type conflict with the primary key of the SQLite database.

@JVasconsueloM

This comment has been minimized.

Copy link

commented Dec 17, 2018

Good morning @ClickSimply, I also have the same bug. As I use a string id, please let me know when version v1.8.0 might come out so I can see what path without return to take to solve this problem (I can not replace my id fields with a uuid because they are necessary for me)

@ClickSimply

This comment has been minimized.

Copy link
Owner

commented Dec 17, 2018

1.8.0 is already released to NPM, sorry if I wasn't clear about that in the original message. :)

@ClickSimply

This comment has been minimized.

Copy link
Owner

commented Dec 21, 2018

Closing this issue, if anyone is still having trouble with this feel free to reply and I'll open the issue again.

@JVasconsueloM

This comment has been minimized.

Copy link

commented Dec 27, 2018

@ClickSimply sorry to delay to reply. I still have this problem on nanoSQL/Cordova when nanosql dont found any record just work with equals key(primarykey and if isn't a array) with or by function filter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.