[Django] #27397: OverflowError at /admin/auth/user/<.id>/change

30 views
Skip to first unread message

Django

unread,
Oct 28, 2016, 8:10:22 AM10/28/16
to django-...@googlegroups.com
#27397: OverflowError at /admin/auth/user/<.id>/change
----------------------------------------------+--------------------
Reporter: Ramin Farajpour Cami | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
Hi,

i don't know, you accept this behavior Overflow on SQLite or there is max
length here?

Step :

http://127.0.0.1:8000/admin/auth/user/1111111111111111111111/change/

Error :

{{{
OverflowError at /admin/auth/user/1111111111111111111111/change/
Python int too large to convert to SQLite INTEGER
Request Method: GET
Request URL:
http://127.0.0.1:8000/admin/auth/user/1111111111111111111111/change/
Django Version: 1.10.2
Exception Type: OverflowError
Exception Value:
Python int too large to convert to SQLite INTEGER
Exception Location: C:\Python27\lib\site-
packages\django\db\backends\sqlite3\operations.py in
_quote_params_for_last_executed_query, line 129
Python Executable: C:\Python27\python.exe
Python Version: 2.7.11
Python Path:
['E:/Programmer Language/NodeJS/untitled1',
'C:\\Users\\RaminFP\\.IntelliJIdea14\\config\\plugins\\python\\helpers\\pydev',
'C:\\Python27\\lib\\site-packages\\six-1.10.0-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\pisa-3.0.33-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\sqlacodegen-1.1.6-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\inflect-0.2.5-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\0x10c_asm-0.0.2-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\jpype1-0.6.1-py2.7-win32.egg',
'C:\\Python27\\lib\\site-packages\\simpleaes-1.0-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\celery-3.1.23-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\kombu-3.0.35-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\anyjson-0.3.3-py2.7.egg',
'C:\\Python27\\lib\\site-packages\\pythonnet-2.1.0.dev1-py2.7-win32.egg',
'E:\\Programmer Language\\NodeJS\\untitled1',
'C:\\Windows\\SYSTEM32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages',
'c:\\python27\\lib\\site-packages']
Server time: Fri, 28 Oct 2016 11:43:05 +0000
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27397>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 28, 2016, 8:21:58 AM10/28/16
to django-...@googlegroups.com
#27397: OverflowError at /admin/auth/user/<.id>/change
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner:
Cami | nickparkin
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by nickparkin):

* status: new => assigned
* needs_better_patch: => 0
* owner: nobody => nickparkin
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:1>

Django

unread,
Oct 28, 2016, 8:28:27 AM10/28/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError

-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner:
Cami | nickparkin
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


Comment:

I'm not sure how to fix that, but it would be nice not to crash if
possible.

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:2>

Django

unread,
Oct 28, 2016, 8:39:05 AM10/28/16
to django-...@googlegroups.com
#27397: OverflowError at /admin/auth/user/<.id>/change
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner:
Cami | nickparkin
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by nickparkin):

* stage: Accepted => Unreviewed


Comment:

I have reproduced this error. This is an error on SQLite side as the
integer is too large to be handled by SQLite.

You will see this error as above when you search for User ID
1111111111111111111111

The max integer is 9223372036854775807. Using this will give you the
following error:

Page not found (404)


Request Method: GET
Request URL:

http://127.0.0.1:8000/admin/auth/user/9223372036854775807/change/
Raised by: django.contrib.admin.options.change_view

Out of interest, if you use the user ID 9223372036854775808, you will get
the same error you saw.

Was not able to recreate the server crashing on my side. It held up fine
and simply throws a Server Error when running under production (Debug =
False).

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:3>

Django

unread,
Oct 28, 2016, 8:44:29 AM10/28/16
to django-...@googlegroups.com
#27397: OverflowError at /admin/auth/user/<.id>/change
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner:
Cami | nickparkin
Type: Bug | Status: closed

Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by nickparkin):

* status: assigned => closed
* resolution: => invalid


Comment:

Looking into if this happens on Postgres now to see if Django is able to
handle of these errors.

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:4>

Django

unread,
Oct 28, 2016, 8:44:48 AM10/28/16
to django-...@googlegroups.com
#27397: OverflowError at /admin/auth/user/<.id>/change
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner:
Cami | nickparkin
Type: Bug | Status: new

Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by nickparkin):

* status: closed => new
* resolution: invalid =>


--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:5>

Django

unread,
Oct 28, 2016, 8:45:10 AM10/28/16
to django-...@googlegroups.com
#27397: OverflowError at /admin/auth/user/<.id>/change
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner:
Cami | nickparkin
Type: Bug | Status: assigned

Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by nickparkin):

* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:6>

Django

unread,
Oct 28, 2016, 8:45:27 AM10/28/16
to django-...@googlegroups.com
#27397: OverflowError at /admin/auth/user/<.id>/change
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner:
Cami | nickparkin
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

Replying to [comment:4 nickparkin]:


> Looking into if this happens on Postgres now to see if Django is able to
handle of these errors.

query can not check max length of valid integer? if check raise on
excpetion

Page not found (404)


Request Method: GET
Request URL:

http://127.0.0.1:8000/admin/auth/user/9223372036854775807/change/
Raised by: django.contrib.admin.options.change_view

check range int after execute query on SQLLite ,

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:7>

Django

unread,
Oct 28, 2016, 9:08:56 AM10/28/16
to django-...@googlegroups.com
#27397: OverflowError at /admin/auth/user/<.id>/change
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner:
Cami | nickparkin
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by nickparkin):

Have confirmed this error by Django handled in Postgres: e.g.
http://127.0.0.1:8000/admin/auth/user/922337203685477582000000000000000000/change/

As such, keeping this open as this could be handled for SQLLite.

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:8>

Django

unread,
Oct 28, 2016, 9:10:04 AM10/28/16
to django-...@googlegroups.com
#27397: OverflowError at /admin/auth/user/<.id>/change
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner:
Cami | nickparkin
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage:
Handling | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by nickparkin):

* keywords: => SQLite, Error Handling


--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:9>

Django

unread,
Oct 28, 2016, 9:21:43 AM10/28/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner:
Cami | nickparkin
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ramin Farajpour Cami):

* stage: Unreviewed => Accepted


Comment:

i test on mysql with many id integer nothing of overflow

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:10>

Django

unread,
Nov 5, 2016, 11:11:24 AM11/5/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami

Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ramin Farajpour Cami):

* owner: nickparkin => Ramin Farajpour Cami


--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:11>

Django

unread,
Nov 5, 2016, 1:17:09 PM11/5/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ramin Farajpour Cami):

* Attachment "excep.diff" added.

Django

unread,
Nov 5, 2016, 1:18:14 PM11/5/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

Hi Tim,

please look this patch and your feedback ,

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:12>

Django

unread,
Nov 5, 2016, 7:53:40 PM11/5/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

[https://github.com/django/django/pull/7513 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:13>

Django

unread,
Nov 6, 2016, 12:33:33 AM11/6/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

Assuming a 404 should be raised wherever an `OverflowError` is raised
doesn't seem correct. A fix at the query level seems more correct. Tests
are also needed.

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:14>

Django

unread,
Nov 6, 2016, 1:29:50 AM11/6/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

Which query change? (please give me python file this query)

max length range define on `sqllite` wherever return `OverflowError ` ,

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:15>

Django

unread,
Nov 6, 2016, 1:10:39 AM11/6/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

For example, I was thinking that `QuerySet.filter()` with a filter
parameter value that overflows (and hence can't match anything) might
return zero results.

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:16>

Django

unread,
Nov 6, 2016, 1:47:14 AM11/6/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

i think you means this , this patch is a very easy Tim, and best way,


{{{
$ git diff HEAD
diff --git a/django/contrib/admin/options.py
b/django/contrib/admin/options.py
index 499d27d..58049ed 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -668,7 +668,7 @@ class ModelAdmin(BaseModelAdmin):
try:
object_id = field.to_python(object_id)
return queryset.get(**{field.name: object_id})
- except (model.DoesNotExist, ValidationError, ValueError):
+ except (model.DoesNotExist, ValidationError, ValueError,
OverflowError):
return None

def get_changelist_form(self, request, **kwargs):

}}}

view :


{{{
Page not found (404)


Request Method: GET
Request URL:

http://127.0.0.1:8000/admin/auth/user/1111111111111111111111111111/change/
Raised by: django.contrib.admin.options.change_view
user object with primary key u'1111111111111111111111111111' does not
exist.
}}}

Overflow Code ;
{{{
return queryset.get(**{field.name: object_id})
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:17>

Django

unread,
Nov 6, 2016, 2:20:01 AM11/6/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

i'm missing for use which test folders
[https://github.com/django/django/tree/master/tests tests] ?

please give me sample python file tests `object_id`, ready for new PR ,


Thanks,
Ramin

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:18>

Django

unread,
Nov 6, 2016, 4:17:36 AM11/6/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

The issue affects all queries, not just those from the admin. A proper fix
my go somewhere in the SQLite database backend
(django/db/backends/sqlite3) but I'm not sure.

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:19>

Django

unread,
Nov 6, 2016, 4:37:59 AM11/6/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

are you sure "The issue affects all queries, not just those from the
admin"? where is issue? i think just happen `object_id` change_view _^ ^_

i test patch is working
(http://127.0.0.1:8000/admin/auth/user/1111111111111111111111/change/),
i need more information a fix,what your means "A proper fix my go


somewhere in the SQLite database backend (django/db/backends/sqlite3)"

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:20>

Django

unread,
Nov 6, 2016, 5:00:38 AM11/6/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

still i'm not sure because i test
http://127.0.0.1:8000/admin/auth/group/11111111111111111111111111111111111111111/change/
nothing error of OverflowError,

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:21>

Django

unread,
Nov 6, 2016, 8:53:39 AM11/6/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

ping Tim,

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:22>

Django

unread,
Nov 7, 2016, 3:06:19 AM11/7/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

The idea is to fix things so that
`Question.objects.filter(id=10000000000000000000)` doesn't crash. Doing so
should also fix the admin.

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:23>

Django

unread,
Nov 7, 2016, 5:30:16 AM11/7/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

{{{
>CREATE TABLE numbers (i INTEGER, r REAL, t TEXT, b BLOB);

>INSERT INTO numbers VALUES (9223372036854775807, 9223372036854775807,
9223372036854775807, 9223372036854775807);

> SELECT * FROM numbers;
i r t b
-------------------- -------------------- --------------------
--------------------
9223372036854775807 9.22337203685478e+18 9223372036854775807
9223372036854775807

> SELECT typeof(i),typeof(r),typeof(t),typeof(b) FROM numbers;
typeof(i) typeof(r) typeof(t) typeof(b)
---------- ---------- ---------- ----------
integer real text integer

> SELECT i+1,r+1,t+1,b+1 FROM numbers;
i+1 r+1 t+1 b+1
-------------------- -------------------- --------------------
--------------------
-9223372036854775808 9.22337203685478e+18 -9223372036854775808
-9223372036854775808

}}}

you see shift +1 and `-9223372036854775808`

INTEGER. The value is a signed integer, stored in 1, 2, 3, 4, 6, or 8
bytes depending on the magnitude of the value.

That is, you can only store values from `-2**63` to `(2**63-1) `

Be careful when you need to store large numbers in SQLite. If you really
need to support unsigned 64-bit numbers, ?? but it makes a SQLite bad
choice for developing

please look :
https://github.com/python/cpython/blob/master/Modules/_sqlite/util.c#L129&L153

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:24>

Django

unread,
Nov 7, 2016, 6:21:52 AM11/7/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

Tim, i see
https://docs.djangoproject.com/en/dev/ref/models/fields/#bigintegerfield ,

do you think change field`id` `int` to `biginteger` is good?

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:25>

Django

unread,
Nov 7, 2016, 8:07:59 AM11/7/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

final patch


{{{


diff --git a/django/contrib/admin/options.py
b/django/contrib/admin/options.py
index 499d27d..58049ed 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -668,7 +668,7 @@ class ModelAdmin(BaseModelAdmin):
try:
object_id = field.to_python(object_id)
return queryset.get(**{field.name: object_id})
- except (model.DoesNotExist, ValidationError, ValueError):
+ except (model.DoesNotExist, ValidationError, ValueError,
OverflowError):
return None

def get_changelist_form(self, request, **kwargs):
diff --git a/django/db/backends/sqlite3/base.py
b/django/db/backends/sqlite3/base.py
index 66ad278..36c1351 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -325,8 +325,11 @@ class SQLiteCursorWrapper(Database.Cursor):
if params is None:
return Database.Cursor.execute(self, query)
query = self.convert_query(query)
- return Database.Cursor.execute(self, query, params)
-
+ try:
+ return Database.Cursor.execute(self, query, params)
+ except OverflowError:
+ return None
+
def executemany(self, query, param_list):
query = self.convert_query(query)
return Database.Cursor.executemany(self, query, param_list)
diff --git a/django/db/backends/sqlite3/operations.py
b/django/db/backends/sqlite3/operations.py
index 47a26b5..6404ea6 100644
--- a/django/db/backends/sqlite3/operations.py
+++ b/django/db/backends/sqlite3/operations.py
@@ -122,6 +122,8 @@ class DatabaseOperations(BaseDatabaseOperations):
# Native sqlite3 cursors cannot be used as context managers.
try:
return cursor.execute(sql, params).fetchone()
+ except OverflowError:
+ return None
finally:
cursor.close()

}}}

usage :


{{{
>>>
User.objects.get(id=1111111111111111111111111111111111111111111111111111111111111111111111111111111111)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python27\lib\site-packages\django\db\models\manager.py", line
85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py", line
385, in get
self.model._meta.object_name
DoesNotExist: User matching query does not exist.
>>>
User.objects.get(id=111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python27\lib\site-packages\django\db\models\manager.py", line
85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py", line
385, in get
self.model._meta.object_name
DoesNotExist: User matching query does not exist.
>>>
User.objects.filter(id=1111111111111111111111111111111111111111111111111111111111111111111111111111111111)
<QuerySet []>
>>>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:26>

Django

unread,
Nov 7, 2016, 11:32:59 AM11/7/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ramin Farajpour Cami):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:27>

Django

unread,
Nov 7, 2016, 5:33:20 PM11/7/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ramin Farajpour Cami):

* Attachment "Overflow_handel.diff" added.

Django

unread,
Nov 7, 2016, 5:36:51 PM11/7/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Ramin Farajpour Cami):

do you confirm fix and patch for PR?


{{{
https://github.com/django/django/blob/master/tests/queries/modles.py

class Ticket27397(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=10)

https://github.com/django/django/blob/master/tests/queries/tests.py

def test_ticket27397(self):
self.assertEqual(len(Ticket27397.objects.filter(id=111111111111111111111111111111111111)),0)

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:28>

Django

unread,
Nov 7, 2016, 5:50:16 PM11/7/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ramin Farajpour Cami):

* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:29>

Django

unread,
Nov 7, 2016, 6:57:42 PM11/7/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

I'm not sure if the fix is the cleanest one, but I'd have to look at the
issue in more detail. I guess you can create a pull request at this point.
You should be able to reuse an existing model for the test.

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:30>

Django

unread,
Nov 8, 2016, 7:49:49 PM11/8/16
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Ramin
Cami | Farajpour Cami
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1
* needs_tests: 1 => 0


Comment:

As noted on the [https://github.com/django/django/pull/7529 PR], the
proposal doesn't work correctly for `QuerySet.exclude()`.

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:31>

Django

unread,
Feb 25, 2023, 1:09:51 PM2/25/23
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Simon
Cami | Charette

Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* owner: (none) => Simon Charette
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:33>

Django

unread,
Feb 25, 2023, 1:18:03 PM2/25/23
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Simon
Cami | Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* needs_better_patch: 1 => 0


Comment:

Submitted a patch that will effectively only address the SQLite issue
reported here when a patch for #34370 lands.

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:34>

Django

unread,
Mar 8, 2023, 7:13:21 AM3/8/23
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Simon
Cami | Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:35>

Django

unread,
Mar 8, 2023, 11:18:29 AM3/8/23
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Simon
Cami | Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Accepted
Handling |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:36>

Django

unread,
Mar 9, 2023, 9:56:55 AM3/9/23
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Simon
Cami | Charette
Type: Bug | Status: assigned
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite, Error | Triage Stage: Ready for
Handling | checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:37>

Django

unread,
Mar 9, 2023, 10:33:09 AM3/9/23
to django-...@googlegroups.com
#27397: Querying with an integer larger than SQLite supports crashes with
OverflowError
-------------------------------------+-------------------------------------
Reporter: Ramin Farajpour | Owner: Simon
Cami | Charette
Type: Bug | Status: closed

Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: SQLite, Error | Triage Stage: Ready for
Handling | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"dde2537fbb04ad78a673092a931b449245a2d6ae" dde2537]:
{{{
#!CommitTicketReference repository=""
revision="dde2537fbb04ad78a673092a931b449245a2d6ae"
Fixed #27397 -- Prevented integer overflows on integer field lookups.

This prevents a sqlite3 crash and address a potential DDoS vector on
PostgreSQL caused by full-table-scans on overflows.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27397#comment:38>

Reply all
Reply to author
Forward
0 new messages