You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Question.update({categoryId: categoryId,questionId: questionId,}).set({enabled: false,type: 'TEXT',// added this}).where((attr,op)=>op.eq(attr.enabled,true)).where((attr,op)=>op.eq(attr.type,'TEXT'))// and this to ensure consistency...
The error in the console says the following - and I have no clue on why I need to supply this value if I am not changing it and unfortunately the link in the error message is broken.
| +1343ms An unknown error occurred: ElectroError: Incomplete composite attributes:
Without the composite attributes "type" the following access patterns cannot be updated:
"byTypeCategoryIdEnabled_questionId_KEYS_ONLY".
If a composite attribute is readOnly and cannot be set, use the 'composite' chain method
on update to supply the value for key formatting purposes. - For more detail on this error
reference: https://electrodb.dev/en/reference/errors/#incomplete-composite-attributes
I would like to learn more on why I need to add this, but I cant find it in the documentation, any help would be appreciated, If I am guided in the right direction, I would send a Pull Request to fix the docs afterwards.
ElectroDB Version
Specify the version of ElectroDB you are using
2.14.0
Entity/Service Definitions
Include your entity model (or a model that sufficiently recreates your issue) to help troubleshoot.
In a nutshell, one of ElectroDB's most important responsibilities is keeping indexes accurate, updated, and in sync. This last part (keeping them in sync) can be difficult because some operations could cause indexes to become out of sync. For example, if an update changes the value of a composite attribute, the impacted index field must also be rewritten. That is what is happening with your example, your change impacts attributes that contribute to the index field kgsi1_pk . ElectroDB identifies that the update will impact that index and will need to update its value as well.
Here's the rub: ElectroDB can't partially update an index. The index field kgsi1_pk has three contributing attributes: type, categoryId, and enabled. In your first query, ElectroDB has access only to categoryId and enabled at the time of update. It needs to update kgsi1_pk but does not have a value to use for type so it cannot create the string necessary to update kgsi1_pk. Your second query does include type so it is able to successfully format the key and continue.
ElectroDB does a lot of work to intelligently limit the amount this constraint impacts queries, but in the case where a key is partially being updated, there's not much else it can do but protect the integrity of the data.
Let me know if you have any further questions, and thanks for the post!
Describe the bug
I am trying to update an item in a transaction but it fails for some reason:
I expect this to work:
but only this works:
The error in the console says the following - and I have no clue on why I need to supply this value if I am not changing it and unfortunately the link in the error message is broken.
I would like to learn more on why I need to add this, but I cant find it in the documentation, any help would be appreciated, If I am guided in the right direction, I would send a Pull Request to fix the docs afterwards.
ElectroDB Version
Specify the version of ElectroDB you are using
2.14.0
Entity/Service Definitions
Include your entity model (or a model that sufficiently recreates your issue) to help troubleshoot.
The text was updated successfully, but these errors were encountered: