django-cursor-pagination
django-cursor-pagination copied to clipboard
Row Value Misused Error
The code that I'm using is very similar to the example provided in the README:
qs = Vendor.objects.filter(client__pk=client_id)
page_size = 2
paginator = CursorPaginator(qs, ordering=('-completed_date', '-id'))
page = paginator.page(first=page_size, after=after)
data = {
'objects': [p for p in page],
'has_next': True,
'last_cursor': paginator.cursor(page[-1])
}
return data
This is working for the first request with the after argument defaulted to None
, but as soon as the after argument is added, I receive the following error row value misused
. This error is caused mainly by the line queryset = queryset.annotate(_cursor=Tuple(*[o.lstrip('-') for o in self.ordering]))
. When accessing the queryset
variable after this line, I receive the error row value misused
. I'm using Django 2.1.5 and sqlite3 2.6.0.
You’ll need a much newer version of SQLite in order for this to work as mentioned in PR #28.
SQLite 2.6.0 was released 2002-07-18, which is positively ancient for software.
Row values were added to SQLite version 3.15.0 (2016-10-14).
https://github.com/photocrowd/django-cursor-pagination/pull/28
Sorry, I should have been more specific. I'm using Python 3.7.0 which has sqlite3 version 2.6.0 as a Python package. But, the sqlite version on my computer is 3.24.0.
Can you check what sqlite3.sqlite_version
is set to?
import sqlite3
sqlite3.sqlite_version
Yep, it's version 3.24.0. I did try upgrade to 3.28.0 but was still getting the same error.
@Drarok @topbloc-beiswenger Any resolution here? I'm having the same experience. Looks like it's related to using a DateTimeField
for ordering.
Good: paginator = CursorPaginator(qs, ordering=('-id',))
Error: paginator = CursorPaginator(qs, ordering=('-created_at', '-id'))
sqlite3: 3.28.0
python: 3.7.6
django: 3.1
django-cursor-pagination: 0.1.4
django-utils-six: 2.0
@craigfay Our team switched to postgres in local development to match our server configuration. This was able to fix the issue. Sorry, but I never found a way to resolve the error with sqlite.
Closing as stale