Closed coeit closed 3 years ago
Responding to the example in section "Pending thoughts"
search: {operator:and, search:[{field:city_id value:"city_1" operator:eq},{field:city_id value:"city_2" operator:eq}]}
Would be converted to
let foreign_keys = helper.intersection_of_associated_foreign_keys_and_search_args_short_param_name( [/* ... */] );
search: {
operator:and,
search:[
{
field:city_id
value: foreign_keys
operator:in
},{
field:city_id
value: foreign_keys
operator:in
}]
}
Only implement this issue for Cassandra.
Traverse the search tree and do the intersections. If any intersection is empty return an empty associated record-array.
Make a note in our Zendro developer manual. If Cassandra / Skylla implements OR
at any time in the future this solutions needs to be fixed in a different approach.
Issue (taken from Slack)
I found a small bug in the backend when resolving a fieldResolver for a many_to_many relation via foreignkeys with a search argument. Example:
results in the following search operator for the countriesConnection
Note how we have two searches on the country_id field combined with an and. One for the search-argument itself and one to filter only the ones associated to the "current" river. While this works fine for postgres, e.g using the following statement
the equivalent might not work for other storagetypes. In cassandra at least it is not allowed to have multiple restrictions on the same field if it includes an "Equal", I'm not sure about other storagetypes.
Solution
Traverse the search tree of the fieldResolver and look for nodes with
operator === 'eq'
andfield === models.<assocModel>.idAttribute()
. If we find a node we need to do an intersection with the asociation argument foreign-key-array and the foundvalue
.Pending thoughts
What about a query with a search like: