[ ] Regression (a behavior that stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Documentation issue or request
Current behavior
My issue is that i have two entities, a calendar which has multiple events. I have set a rule that requires an event to have exactly one calendar. The problem is if a parent calendar is deleted this removes the calendar from the events and we are left with orphaned events.
I realise this means we cannot guarantee that an event has an associated calendar however I also cannot filter these orphaned events out using an odata query.
{
"filter": "data/calendar/iv/$count eq 0"
}
To which i get the response " “message”: “OData $filter clause not valid: The next token in a CountSegmentNode must be a collection.”,"
I assume this is because Squidex doesn’t support all odata.
I cannot deal with this server side as filtering out some results will cause problems with pagination.
Any advice on how to handle this? The only thing I can think of is to use a hook to go in and delete the orphaned events after the fact
The root cause is how references are handled. When you have a reference the ID is added to the document in the database.
Before the content is returned by the API, the API checks whether the references are still valid and removes all non-existing references from the API result, but not from the database. It cannot modify the database because this could cause issues when the content is modified at the same time.
Your content in the database still has a reference to a calendar entry:
Therefore the query operator does not work, because when the query is executed it is converted to a database filter and for the database the calendar field is not empty.
Right now I do not have a solution for that, I am sorry.