django-cursor-pagination icon indicating copy to clipboard operation
django-cursor-pagination copied to clipboard

Row Value Misused Error

Open topbloc-beiswenger opened this issue 5 years ago • 6 comments

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.

topbloc-beiswenger avatar Jul 09 '19 14:07 topbloc-beiswenger

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

Drarok avatar Jul 09 '19 21:07 Drarok

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.

topbloc-beiswenger avatar Jul 17 '19 16:07 topbloc-beiswenger

Can you check what sqlite3.sqlite_version is set to?

import sqlite3
sqlite3.sqlite_version

Drarok avatar Jul 18 '19 01:07 Drarok

Yep, it's version 3.24.0. I did try upgrade to 3.28.0 but was still getting the same error.

topbloc-beiswenger avatar Jul 18 '19 01:07 topbloc-beiswenger

@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 avatar Aug 24 '20 20:08 craigfay

@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.

topbloc-beiswenger avatar Aug 25 '20 14:08 topbloc-beiswenger

Closing as stale

thommor avatar Nov 22 '22 19:11 thommor