-
Type:
Bug
-
Status: Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 10.10
-
Fix Version/s: 10.10-HF58, 2021.15
-
Component/s: Core MongoDB
-
Release Notes Summary:Enabling unique child constraint doesn't prevent version creation anymore
-
Tags:
-
Backlog priority:750
-
Upgrade notes:
-
Sprint:nxplatform #52, nxplatform #53
-
Story Points:0
For MongoDB repository, Nuxeo adds a unique index on "ecm:name ; ecm:parentId" to prevent from creating several documents with the same name in a given container with
IndexOptions parentNameIndexOptions = new IndexOptions(); parentNameIndexOptions.unique(true); coll.createIndex(Indexes.ascending(KEY_PARENT_ID, KEY_NAME), parentNameIndexOptions);
However this index prevents from creating versions (there is an error when creating the second version as it has the same name and the same "null" parent).
It is required to add a partialFilterExpression attribute on the index creation like
db.default.createIndex( { "ecm:parentId": 1, "ecm:name": 1 }, { unique: true, partialFilterExpression: {'ecm:parentId':{$gt:""}} } )