-
-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support select(Model.column1, Model.column2) in pagination #1168
Comments
I am having the same issues upgrading to SQLAlchemy 2.0.x with lots of Model.query.with_entities(...).filter().order_by().paginate(). All these seem to return only the id per row, not the remaining fields in with_entities(...) In the code of pagination.py I found this on line 335:
when I change it to:
And use
and
then I do get the columns with dict(d._mapping) for d in res. Not sure, though, if this is the correct solution for all situation? |
I would also like to have this fixed, it seems to me a regression. It was working fine with SQLAlchemy 1.4 version and Flask-SQLAlchemy 2.x |
Because SQLAlchemy doesn't provide a way to introspect whether a query will return a model instance or rows. The primary use case is From the docs:
|
I'm using the legacy query object too for now, because |
Happy to review a PR. Just saying "me too" isn't helpful though. This is an community open source project. If a feature is important to you, you can implement it. |
Thanks for working on it. That's an easy to implement new method. But that doesn't solve the problem that people will call paginate first and then still think there's an issue. Based on what people have asked for, it sounds like they want one method that handles both cases automatically. That's what we need help with, someone to investigate how to do that, or follow up with SQLAlchemy about making it possible. |
@davidism At the moment, I believe the primary issue is that there isn't a way to paginate compound selects without either using the legacy |
I am just wondering if there is a way to preserve the column names on the paginate_rows() method? |
@davidism I agree with jwodder. At the moment flask-sqlalchemy is defect as there is no way to paginate queries that select individual columns. Without it many users are stuck at flask-sqlalchemy 2.5.1 as rewriting complex sqlalchemy queries is not an option just to be able to do pagination again. So please accept |
#1100 says that db.paginate currently not work for select(Model.column1, Model.column2), so will this feature going to be implemented in a future version, or what could I do to get this?
The text was updated successfully, but these errors were encountered: