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

unique constraint fails every second time #36

Closed
fceller opened this issue Apr 1, 2012 · 0 comments
Closed

unique constraint fails every second time #36

fceller opened this issue Apr 1, 2012 · 0 comments
Assignees

Comments

@fceller
Copy link
Contributor

fceller commented Apr 1, 2012

I've encountered a strange bug and have no idea, where it comes from:

AvocadoDB shell [V8 version 3.8.5, DB version 0.3.5]
avocado> db.examples.ensureUniqueConstraint("a")
{ "id" : 1194947, "unique" : true, "type" : "hash", "fields" : ["a"], "isNewlyCreated" : true }
avocado> x = db.examples.save({ a : 1, b : 1 })
80835/1653699
avocado> db.examples.document(x)
{ "_id" : "80835/1653699", "_rev" : 1653699, "a" : 1, "b" : 1 }
avocado> x = db.examples.save({ a : 1, b : 2 })
JavaScript exception in file '(avocado)' at 1,17: cannot save document: unique constraint violated
!x = db.examples.save({ a : 1, b : 2 })
! ^
avocado> db.examples.document(x)
{ "_id" : "80835/1653699", "_rev" : 1653699, "a" : 1, "b" : 1 }
avocado> db.examples.toArray()
[{ "_id" : "80835/1653699", "_rev" : 1653699, "a" : 1, "b" : 1 }]
avocado> x = db.examples.save({ a : 1, b : 2 })
80835/1981379
avocado> db.examples.toArray()
[{ "_id" : "80835/1653699", "_rev" : 1653699, "a" : 1, "b" : 1 }, { "_id" : "80835/1981379", "_rev" : 1981379, "a" : 1, "b" : 2 }]
avocado> bye...

The first save creates a document => fine
the second save gives a constraint violation => fine
the third save creates a document without violation => I've no idea why

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