Skip to content

Commit

Permalink
Convert query sequence values to list
Browse files Browse the repository at this point in the history
Queries `In` and `NotIn` now accept any sequence of values.
Internally the sequence is converted to a list, for compatibility
with API query filters.
  • Loading branch information
padraic-shafer committed Jan 18, 2023
1 parent 145b348 commit f27215d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tiled/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def decode(cls, *, key, value):
@dataclass
class In:
"""
Query if a given key's value is present in the specified list of values.
Query if a given key's value is present in the specified sequence of values.
Parameters
----------
Expand All @@ -335,6 +335,9 @@ class In:
key: str
value: List[JSONSerializable]

def __post_init__(self):
self.value = list(self.value)

def encode(self):
return {"key": self.key, "value": json.dumps(self.value)}

Expand All @@ -347,7 +350,7 @@ def decode(cls, *, key, value):
@dataclass
class NotIn:
"""
Query if a given key's value is not present in the specified list of values.
Query if a given key's value is not present in the specified sequence of values.
Parameters
----------
Expand All @@ -367,6 +370,9 @@ class NotIn:
key: str
value: List[JSONSerializable]

def __post_init__(self):
self.value = list(self.value)

def encode(self):
return {"key": self.key, "value": json.dumps(self.value)}

Expand Down

0 comments on commit f27215d

Please sign in to comment.