2
votes

I just read the issue from arangoDB github [1.1] Feature request: On unique constrain violation exceptions include ids or keys that were involved #342 (https://github.com/arangodb/arangodb/issues/342) because it is exactly what I was searching for. Apparently this issue is already closed because it has been implemented in ArangoDB 3.2, however I do not find the way to retrieve the id or key from a unique constraint violation error.

For example I call the following AQL query on a collection with a Hash Index on "projectName" attribute.

# first insert - everything OK
INSERT {"projectName":"test","startDate":"now"} IN projects
RETURN NEW

# second insert - will give unique constraint violation error
INSERT {"projectName":"test","startDate":"tomorrow"} IN projects
RETURN NEW

Therefore the error that I get is: AQL: unique constraint violated (while executing). Errors: {u'code': 409, u'errorNum': 1210, u'errorMessage': u'AQL: unique constraint violated (while executing)', u'error': True} with no _key or _id or something that tells me with which document do I have a unique constraint violation. Based on the closed issue it should be possible but I don't see how, or maybe I just understood it wrong.

Note: A similar question was posted in Determining which unique constraint caused INSERT failure in ArangoDB but I think it was answered before the release of ArangoDB 3.2

I am using ArangoDB 3.2.3

Thanks

1

1 Answers

1
votes

It looks like that the index details are still omitted when triggering a unique constraint violation from within AQL. In this case it will only show/return a generic "unique constraint violated", but not indicate which index caused it.

This is unintentional, and there is now a pull request to fix this:

https://github.com/arangodb/arangodb/pull/3330