Attribute ident can't be retarget when the attribute is part of composite attribute

For some needs I have some alias ident which is moved from one attribute to another one.

Original schema is:

(def post-schema [
                   {
                       :db/ident :Post/title.version.1
                       :db/valueType :db.type/string
                       :db/cardinality :db.cardinality/one
                       :db/fulltext true
                       :IModel/type "db"
                   }
                    {
                       :db/ident :Post/title.version.2
                       :db/valueType :db.type/string
                       :db/cardinality :db.cardinality/one
                       :db/fulltext true
                       :IModel/type "db"
                   }
                   {
                       :db/ident :Post/category
                       :db/valueType :db.type/string
                       :db/cardinality :db.cardinality/one
                       :IModel/type "db"
                   }
                ])
(d/transact connInternal post-schema)

And alias is set firstly for :Post/title.version.1

 (d/transact
      connInternal 
[[:db/add :Post/title.version.1 :db/ident :Post/title]] )

Now, I need to use :Post/title for :Post/title.version.2, it is done very easily by executing the next statements:

 ; Retracting of alias from first version and setting for second one

 (d/transact
      connInternal 
[[:db/add :Post/title :db/ident :Post/title.version.1] ] )

 (d/transact
      connInternal 
[[:db/add :Post/title.version.2 :db/ident :Post/title]] )

So all works fine until :Post/title.version.1 is part of composite attribute, the above statements do not work if the schema is the next:

(def post-schema [
                   {
                       :db/ident :Post/title.version.1
                       :db/valueType :db.type/string
                       :db/cardinality :db.cardinality/one
                       :db/fulltext true
                       :IModel/type "db"
                   }
                   {
                       :db/ident :Post/title.version.2
                       :db/valueType :db.type/string
                       :db/cardinality :db.cardinality/one
                       :IModel/type "db"
                   }
                  {
                       :db/ident :Post/category
                       :db/valueType :db.type/string
                       :db/cardinality :db.cardinality/one
                       :IModel/type "db"
                   }
                 {
                       :db/ident :Post/title.category
                       :db/valueType :db.type/tuple
                       :db/cardinality :db.cardinality/one
                       :db/tupleAttrs [:Post/title.version.1 :Post/category]
                       :IModel/type "db"
                   }
                ])
(d/transact connInternal post-schema)

In such case

 (d/transact
      connInternal 
[[:db/add :Post/title :db/ident :Post/title.version.1] ] )

is executed successfully, even the history shows, that alias ident has been retracted:

But once the next statement is executed:

 (d/transact
      connInternal 
[[:db/add :Post/title.version.2 :db/ident :Post/title]] )

Then the next error happens:

{:cognitect.anomalies/category :cognitect.anomalies/incorrect, :cognitect.anomalies/message "Ident :Post/title cannot be used for entity :Post/title.version.2, already used for :Post/title.version.1", :db/error :db.error/cannot-retarget-ident}

The error states that :Post/title is hold by :Post/title.version.1, but the history confirms that :Post/title is not linked to :Post/title.version.1

Datomic on-prem 0.9.6045

2 Likes