Skip to content

Commit

Permalink
Apply offset only if not null
Browse files Browse the repository at this point in the history
  • Loading branch information
marioncottard committed Aug 22, 2023
1 parent f37fee1 commit 11eccdc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cornflow-server/cornflow/models/meta_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def get_all_objects(
"""
if "user" in kwargs:
kwargs.pop("user")
query = cls.query.filter_by(**kwargs).offset(offset)
query = cls.query.filter_by(**kwargs)
if offset:
query = query.offset(offset)
if limit:
query = query.limit(limit)
return query
Expand Down Expand Up @@ -300,7 +302,8 @@ def get_all_objects(
if creation_date_lte:
query = query.filter(cls.created_at <= creation_date_lte)

query = query.offset(offset)
if offset:
query = query.offset(offset)
if limit:
query = query.limit(limit)
return query
Expand Down

0 comments on commit 11eccdc

Please sign in to comment.