-
Notifications
You must be signed in to change notification settings - Fork 714
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
PouchDB document-root table max_seq column not being set #226
Comments
AFAIK the If this is allowed by http://www.w3.org/TR/webdatabase/, I cannot see it. Simplest solution suggested is to fix the PouchDB websql adapter. |
@hgo If you could provide a live reproducible example or a sample Cordova app, that would be very helpful. :) We have over 1,000 unit tests for PouchDB, and this issue has never come up, so maybe your app has found a very special corner case. |
Also yeah, this is probably a bug on PouchDB unless the bug only occurs for the SQLite Plugin and not for WebSQL (e.g. in Safari/Chrome). |
It's reproducible here: https://github.com/hgo/sp to build & run please run commands below
Adapter is being set here |
I'm sorry, but I can't reproduce in either Kitkat or Lollipop when I run your example. Also it has a bug: you forgot to include
which is caused by a line in
Even when I fix that, though (by adding
Maybe you are using a different version of the Ionic CLI than me? I'm using 1.3.19. Also, if you could please reproduce your bug without using the SQLite plugin (i.e. using the built-in WebSQL adapter), then that would immediately tell us whether this bug is in the SQLite plugin or in PouchDB. And if it is a bug in PouchDB, then a live HTML example that doesn't require running Ionic/Cordova would probably be easier to debug. Thanks. :) |
Ah, I just noticed your comment:
So if that's the case, then it seems this is indeed a bug in the SQLite plugin. |
ah, i'm sorry, it was ionic keyboard
It's not reproducible on standart Webkit / Chrome or Safari browsers. websql adapter works fine with them. The problem only occurs with If you remove plugin everything works fine. Also I noticed that my repo contains the corrupted db here. luckily :) |
Ah, okay. Does it occur in iOS or only Android? Sorry for being a bother, but it helps to narrow down the root of the problem. :) |
Sorry I did not tested on iOS yet. I will update the comment when I try. |
Unfortunately I still cannot understand the real issue. I just made the following Jasmine test, which passes on both the plugin and browser built-in, on both Android and iOS: it(suiteName + "INTEGER UNIQUE column not filled in",
function(done) {
var db = openDatabase("INTEGER-UNIQUE-column-not-filled-in.db", "1.0", "Demo", DEFAULT_SIZE);
expect(db).toBeDefined();
db.transaction(function(tx) {
expect(tx).toBeDefined();
tx.executeSql("DROP TABLE IF EXISTS 'document-store'");
tx.executeSql("CREATE TABLE 'document-store' (id unique, json, winningseq, max_seq INTEGER UNIQUE)");
tx.executeSql("insert into 'document-store' (json) values (?)", ['[1,2]']);
tx.executeSql("insert into 'document-store' (json) values (?)", ['[3,4]'], function(tx, res) {
// correct:
expect(true).toBe(true);
}, function(err) {
// not expected:
expect(false).toBe(true);
return false;
});
}, function(err) {
// should not get here:
expect(false).toBe(true);
done();
}, function() {
// verify tx was ok:
expect(true).toBe(true);
done();
});
}, MYTIMEOUT); |
Great, could you add some checks to test above, that tests |
Looking at
Looking at |
Also if I change my test: it(suiteName + "INTEGER UNIQUE column not filled in",
function(done) {
var db = openDatabase("INTEGER-UNIQUE-column-not-filled-in.db", "1.0", "Demo", DEFAULT_SIZE);
expect(db).toBeDefined();
db.transaction(function(tx) {
expect(tx).toBeDefined();
tx.executeSql("DROP TABLE IF EXISTS 'document-store'");
tx.executeSql("CREATE TABLE 'document-store' (id unique, json, winningseq, max_seq INTEGER UNIQUE)");
//tx.executeSql("insert into 'document-store' (json) values (?)", ['[1,2]']);
//tx.executeSql("insert into 'document-store' (json) values (?)", ['[3,4]'], function(tx, res) {
tx.executeSql("insert into 'document-store' (json, max_seq) values (?)", ['[1,2]', null]);
//tx.executeSql("insert into 'document-store' (json, max_seq) values (?)", ['[3,4]', null]);
tx.executeSql("insert into 'document-store' (json, max_seq) values (?)", ['[3,4]', null], function(tx, res) {
// correct:
expect(true).toBe(true);
}, function(err) {
// not expected:
expect(false).toBe(true);
return false;
});
}, function(err) {
// should not get here:
expect(false).toBe(true);
done();
}, function() {
// verify tx was ok:
expect(true).toBe(true);
done();
});
}, MYTIMEOUT); it fails in slightly different ways when run against the plugin and HTML5/WebKit versions of This observation appears to be related to #232, but I would like to continue with more testing before drawing any conclusions. My aim is to keep this plugin working as consistently as possible with both the HTML5/Web SQL API, as specified at http://www.w3.org/TR/webdatabase/, and the existing WebKit implementation found in Android (Chrome mobile) and iOS (mobile Safari). I think we can conclude that in my first test, sqlite would automatically populate the |
I'm trying to put a document to db on an android device with Cordova-SQLitePlugin , this exception being thrown all time.
a statement with no error handler failed: column max_seq is not unique (code 19)
After some investigation I found out that
document-store
table has a column namedmax_seq
which holds a sequence number, and in device it is not being filled, so first item being inserted with null value (i guess it is a corruption) then other insertions not being completed and the exception above being thrown because thismax_seq
column has anunique
index.CREATE TABLE 'document-store' (id unique, json, winningseq, max_seq INTEGER UNIQUE)
In a browser everything works fine,
max_seq
column is being filled incrementally for each row.Am i missing to set an option while creating the db or is this a defect ?
I guess @nolanlawson is following the issues about PouchDB
Thanks!
Note: Android device 4.4.4
The text was updated successfully, but these errors were encountered: