首页 文章

ArangoDB 3.2唯一约束违反_id或_key

提问于
浏览
2

我刚刚从arangoDB github [1.1] Feature request: On unique constrain violation exceptions include ids or keys that were involved #342https://github.com/arangodb/arangodb/issues/342)中读到了这个问题,因为它正是我所寻找的 . 显然这个问题已经关闭,因为它已经在ArangoDB 3.2中实现,但是我没有找到从唯一约束违规错误中检索id或密钥的方法 .

例如,我在具有“projectName”属性的哈希索引的集合上调用以下AQL查询 .

# 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

因此,我得到的错误是: 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} 没有_key或_id或者告诉我哪个文档有唯一约束违规的东西 . 根据封闭的问题,它应该是可能的,但我不知道如何,或者我只是理解它错了 .

注意:在Determining which unique constraint caused INSERT failure in ArangoDB中发布了一个类似的问题,但我认为它在ArangoDB 3.2发布之前得到了解答

我正在使用ArangoDB 3.2.3

谢谢

1 回答

  • 1

    看起来在从AQL中触发唯一约束违规时仍然会省略索引详细信息 . 在这种情况下,它将仅显示/返回通用的“违反唯一约束”,但不指示导致它的索引 .

    这是无意的,现在有一个拉取请求来解决这个问题:

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

相关问题