Skip to content

Commit

Permalink
Added negate to iterables inside Query
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Casanovas committed Apr 12, 2024
1 parent da4548e commit 91f5c0d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions O365/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ def endswith(self, word):

@fluent
def iterable(self, iterable_name, *, collection, word, attribute=None, func=None,
operation=None):
operation=None, negate=False):
""" Performs a filter with the OData 'iterable_name' keyword
on the collection
Expand All @@ -1134,6 +1134,7 @@ def iterable(self, iterable_name, *, collection, word, attribute=None, func=None
the collection
:param str operation: the logical operation to apply to the attribute
inside the collection
:param bool negate: negate the funcion or operation inside the iterable
:rtype: Query
"""

Expand All @@ -1156,9 +1157,9 @@ def iterable(self, iterable_name, *, collection, word, attribute=None, func=None
attribute = 'a/{}'.format(attribute)

if func is not None:
sentence = self._prepare_function(func, attribute, word)
sentence = self._prepare_function(func, attribute, word, negate)
else:
sentence = self._prepare_sentence(attribute, operation, word)
sentence = self._prepare_sentence(attribute, operation, word, negate)

filter_str, attrs = sentence

Expand All @@ -1170,7 +1171,7 @@ def iterable(self, iterable_name, *, collection, word, attribute=None, func=None
return self

@fluent
def any(self, *, collection, word, attribute=None, func=None, operation=None):
def any(self, *, collection, word, attribute=None, func=None, operation=None, negate=False):
""" Performs a filter with the OData 'any' keyword on the collection
For example:
Expand All @@ -1188,14 +1189,16 @@ def any(self, *, collection, word, attribute=None, func=None, operation=None):
inside the collection
:param str operation: the logical operation to apply to the
attribute inside the collection
:param bool negate: negate the funcion or operation inside the iterable
:rtype: Query
"""

return self.iterable('any', collection=collection, word=word,
attribute=attribute, func=func, operation=operation)
attribute=attribute, func=func, operation=operation,
negate=negate)

@fluent
def all(self, *, collection, word, attribute=None, func=None, operation=None):
def all(self, *, collection, word, attribute=None, func=None, operation=None, negate=False):
""" Performs a filter with the OData 'all' keyword on the collection
For example:
Expand All @@ -1213,11 +1216,13 @@ def all(self, *, collection, word, attribute=None, func=None, operation=None):
inside the collection
:param str operation: the logical operation to apply to the
attribute inside the collection
:param bool negate: negate the funcion or operation inside the iterable
:rtype: Query
"""

return self.iterable('all', collection=collection, word=word,
attribute=attribute, func=func, operation=operation)
attribute=attribute, func=func, operation=operation,
negate=negate)

@fluent
def order_by(self, attribute=None, *, ascending=True):
Expand Down

0 comments on commit 91f5c0d

Please sign in to comment.