-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Hi!
I've faced some issue with list filter and find some improvement that can help filter by list
class Query...
# your solution
def filter(self, value) -> "Query[Q]":
"""
Set ``$filter`` query parameter. Can be called multiple times. Multiple
:py:func:`filter` calls are concatenated with 'and'
:param value: Property comparison. For example, ``Entity.Property == 2``
:return: Query instance
"""
q = self._new_query()
option = q._get_or_create_option('$filter')
option.append(value)
return qImprovement to extend list filter
class Query...
# my solution
def filter(self, value) -> "Query[Q]":
"""
Set ``$filter`` query parameter. Can be called multiple times. Multiple
:py:func:`filter` calls are concatenated with 'and'
:param value: Property comparison. For example, ``Entity.Property == 2``
:return: Query instance
"""
q = self._new_query()
option = q._get_or_create_option('$filter')
if isinstance(value, list):
option.extend(value)
else:
option.append(value)
return qe.g.
entity = entities[my_entity]
q = query(entity)
exclude_sids = ['6f98ba36-3b7f-4767-8369-88a65578dc5a', '5afa06fb-3b66-4216-8681-56acdeac7fc1']
sid_filters = [group_entity.Sid != i for i in exclude_sids]
# filters by odata filter[Sid ne 6f98ba36-3b7f-4767-8369-88a65578dc5a, Sid ne 5afa06fb-3b66-4216-8681-56acdeac7fc1]
q = q.filter(sid_filters).all()
# output log
# Query: {'$filter': '(Sid ne 6f98ba36-3b7f-4767-8369-88a65578dc5a) and (Sid ne 5afa06fb-3b66-4216-8681-56acdeac7fc1)Kind regard, Pavel
Metadata
Metadata
Assignees
Labels
No labels