Skip to content

Commit

Permalink
only filter by the query parameters, not by all fields in the pydanti…
Browse files Browse the repository at this point in the history
…c model
  • Loading branch information
dantownsend committed Oct 30, 2019
1 parent 3e4c295 commit bc5c38e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions piccolo_api/crud/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ async def _get_all(self, params: t.Optional[t.Dict] = None):
"""
query = self.table.select()
if params:
model = self.pydantic_model(**params)
for field_name, value in model.dict().items():
model_dict = self.pydantic_model(**params).dict()
for field_name in params.keys():
value = model_dict[field_name]
if type(value) == str:
query = query.where(
getattr(self.table, field_name).ilike(f"%{value}%")
Expand Down

0 comments on commit bc5c38e

Please sign in to comment.