Skip to content

Commit

Permalink
Merge pull request #110 from pagreene/add-bc-features
Browse files Browse the repository at this point in the history
Add backwards-compatibility features back in
  • Loading branch information
pagreene committed Jun 3, 2020
2 parents 0f714dc + 723d435 commit 911b48f
Show file tree
Hide file tree
Showing 3 changed files with 562 additions and 16 deletions.
25 changes: 25 additions & 0 deletions indra_db/client/readonly/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,31 @@ def is_inverse_of(self, other):
return self._inverted != other._inverted


class EmptyQuery:
def __and__(self, other):
if not isinstance(other, QueryCore):
raise TypeError(f"Cannot perform __and__ operation with "
f"{type(other)} and EmptyQuery.")
return other

def __or__(self, other):
if not isinstance(other, QueryCore):
raise TypeError(f"Cannot perform __or__ operation with "
f"{type(other)} and EmptyQuery.")
return other

def __sub__(self, other):
if not isinstance(other, QueryCore):
raise TypeError(f"Cannot perform __sub__ operation with "
f"{type(other)} and EmptyQuery.")
return other.invert()

def __eq__(self, other):
if isinstance(other, EmptyQuery):
return True
return False


class SourceCore(QueryCore):
"""The core of all queries that use SourceMeta."""

Expand Down

0 comments on commit 911b48f

Please sign in to comment.