codemation / pydbantic

A single model for shaping, creating, accessing, storing data within a Database
https://pydbantic.readthedocs.io/en/latest/
Apache License 2.0
228 stars 15 forks source link

BUG - Filtering with order_by & limit / offset #32

Closed codemation closed 2 years ago

codemation commented 2 years ago

Description

On version 0.0.21, filtering might fail if queries specify both order_by combined with limit and offset.

Traceback

(order_by=order, limit=limit, offset=offset)
  File "/usr/local/lib/python3.8/site-packages/pydbantic/core.py", line 1143, in all
    return await cls.select('*', **parameters, backward_refs=backward_refs)
  File "/usr/local/lib/python3.8/site-packages/pydbantic/core.py", line 966, in select
    sel = sel.order_by(order_by)
  File "<string>", line 2, in order_by
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/sql/base.py", line 110, in _generative
    x = fn(self, *args, **kw)
  File "<string>", line 2, in order_by
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/base.py", line 229, in generate
    assertion(self, fn.__name__)
  File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 312, in _no_limit_offset
    raise sa_exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: Query.order_by() being called on a Query which already has LIMIT or OFFSET applied.  Call order_by() before limit() or offset() are applied.
codemation commented 2 years ago

Fixed in 0.0.22