Doesn't throw necessary errors
Closed this issue · 3 comments
Hi grncdr,
Looks like any-db will avoid key constraint violation. It doesn't throw an error when I insert 2 duplicate keys into sqlite3 database. Is that what any-db really does or just a special case on me?
Thanks.
If it is caused by any-db, it's certainly not intentional. Could you maybe provide a test script that demonstrates the problem?
The test script below works for me. If it doesn't work on your system, please re-open the issue with the versions of any-db-sqlite3
and sqlite3
that are being used.
var assert = require('assert')
var adapter = require('any-db-sqlite3')
adapter.createConnection({}, function (err, conn) {
conn.query("CREATE TABLE whatever (id int, data text, primary key (id))")
conn.query("INSERT INTO whatever VALUES (1, 'blah blah')", function (err) {
assert(!err, err)
})
conn.query("INSERT INTO whatever VALUES (1, 'blah blah')", function (err) {
assert(err, "conflict error not returned to callback")
assert.equal(err.code, 'SQLITE_CONSTRAINT')
})
})
Hello,
I used two separate modules, any-db and sqlite3, instead of any-db-sqlite3.
Actually, I planed to give you guys the test script after completing my
current project.
Thanks,
Zhixiong
On Wed, Mar 12, 2014 at 2:56 AM, Stephen Sugden notifications@github.comwrote:
The test script below works for me. If it doesn't work on your system,
please re-open the issue with the versions of any-db-sqlite3 and sqlite3that are being used.var assert = require('assert')var adapter = require('any-db-sqlite3')
adapter.createConnection({}, function (err, conn) {
conn.query("CREATE TABLE whatever (id int, data text, primary key (id))")
conn.query("INSERT INTO whatever VALUES (1, 'blah blah')", function (err) {
assert(!err, err)
})
conn.query("INSERT INTO whatever VALUES (1, 'blah blah')", function (err) {
assert(err, "conflict error not returned to callback")
assert.equal(err.code, 'SQLITE_CONSTRAINT')
})})Reply to this email directly or view it on GitHubhttps://github.com//issues/57#issuecomment-37380437
.