-
Notifications
You must be signed in to change notification settings - Fork 521
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
Unique constraint failed error - 2067 with pouchdb-mapreduce- Android #107
Comments
Unique constraint errors have nothing to do with this library, this is SQL related. Check the database schema and especially all unique indexes and primary keys. There should be the root cause of your exception |
I am understanding what you are saying but the thing is same js wrapper is working fine on ios but only throwing error for android on same data set and same query execution. |
i think i got the issue. my id field contains \u000 character which was constructed by pouchdb-mapreduce and thats not supported for cordova-sqlite-storage. |
@brodybits - Chris hi, is this something that has been identified in the core cordova-storage module and can be fixed? |
@SuhailMehta Hi, did you manage it? Seems like pouchdb is heavily using \u0000 for indexing. |
It seems that '\u000' is wrongfully interpreted as '\0' on some platforms and thus the issue. I have found some mentions of it on the pouchdb website. Perhaps newer versions of PouchDB shy away from using this character? |
I think it's react native-related problem: facebook/react-native#12731 |
@noradaiko I have change '\u0000' in pouchdb to '\u0001' in pouchdb internals. I think if you will dig inside sql adapter or if you will read its(sql adapter) read me you have to replace '\u0000' to '\u0001' for some platforms (android platform for me). |
@SuhailMehta Thanks for the answer. Instead, I made react-native-sqlite-2 which code base is from Nolan's cordova-plugin-sqlite-2 with my patch for this problem, and it works pretty well on both Android and iOS for now. |
I am working on react-native project which uses sync so we decided to use couch-pouch. With pouchdb websql adapter i am using your your sqlite storage which is working fine for ios app but when we try to run the same app on android its was able to insert data from couch to sqlite storage but when we query the data it throws an error pointing Unique constraint failed for document-store.id (error - 2067).
With pouchdb-mapreduce i can see the _pouch_dbName-mrview db being created but it was empty.
So, before query the indexes insert must be done for a view but as db is empty i can't under why unique constraints are failing.
Can you suggest the a way to resolve it or i can add some more information to it.
The text was updated successfully, but these errors were encountered: