Skip to content
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

paging doesn't work with custom types in ordering #6

Closed
liebald opened this issue Sep 23, 2017 · 1 comment · Fixed by #27
Closed

paging doesn't work with custom types in ordering #6

liebald opened this issue Sep 23, 2017 · 1 comment · Fixed by #27

Comments

@liebald
Copy link

liebald commented Sep 23, 2017

We're using SQLAlchemyUtils' ArrowType for representing datetime fields in our models (as opposed to plain Python datetimes). This works fine with the rest of SQLAlchemy, but seems to cause problems with sqlakeyset when a column with this type is used in an ordering clause.

In particular, here's a simple example that fails:

In [62]: q = db.session.query(m.Conversation).order_by(m.Conversation.modified_at.desc())

In [63]: results = get_page(q, per_page=20)

In [64]: results.paging.next
Out[64]: ((<Arrow [2017-07-20T16:12:35+00:00]>,), False)

In [65]: results2 = get_page(q, per_page=20, page=results.paging.next)
---------------------------------------------------------------------------
ProgrammingError                          Traceback (most recent call last)
# Exception stack trace...
ProgrammingError: (psycopg2.ProgrammingError) can't adapt type 'Arrow'
# query details...

I'm not entirely sure how custom types like ArrowType work, but it looks like the type conversion that typically happens is skipped here, and as a result the lower-level psycopg2 library doesn't know what to do with this type.

Any idea how to fix this?

@djrobstep
Copy link
Owner

Hi there, thanks for filing this issue!

As you suggest, the type conversion is getting skipped for some reason.

Something in the query manipulation in orm_get_page is stopping this from happening.

Unfortunately I'm super busy right now and don't have the time to dig into this further and fix it up. However if you want to fix it and send a pull request, I'd be delighted to receive it!

It would also be cool to hear more about how you're using sqlakeyset and how well it's worked for you, aside from this issue that is. As this still a fairly new project, it's a challenge to get good feedback from real users.

acarapetis added a commit to acarapetis/sqlakeyset that referenced this issue Dec 27, 2019
acarapetis added a commit to acarapetis/sqlakeyset that referenced this issue Dec 27, 2019
acarapetis added a commit to acarapetis/sqlakeyset that referenced this issue Feb 24, 2020
acarapetis added a commit to acarapetis/sqlakeyset that referenced this issue Feb 29, 2020
acarapetis added a commit to acarapetis/sqlakeyset that referenced this issue Jul 14, 2020
acarapetis added a commit to acarapetis/sqlakeyset that referenced this issue Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants