[Django] #32585: Type Error when annotating a decimal to decimal field with SQLite3

29 views
Skip to first unread message

Django

unread,
Mar 22, 2021, 1:19:53 PM3/22/21
to django-...@googlegroups.com
#32585: Type Error when annotating a decimal to decimal field with SQLite3
-------------------------------------+-------------------------------------
Reporter: Adrian | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 3.1
layer (models, ORM) | Keywords: SQLite3, annotate,
Severity: Normal | decimal
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
If you try to annotate anything to a decimal field Django will pass a
string to create_decimal_from_float function.

[https://github.com/django/django/blob/021f946569d0714fccd090bb2a5f1d7ab2720447/django/db/backends/sqlite3/operations.py#L304-L318
These are the offending lines]

example code:

{{{
SomeModel.objects.all().annotate(shear_length=Value(1,
output_field=DecimalField()))
}}}

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

Django

unread,
Mar 22, 2021, 1:21:08 PM3/22/21
to django-...@googlegroups.com
#32585: Type Error when annotating a decimal to decimal field with SQLite3
-------------------------------------+-------------------------------------
Reporter: Adrian | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite3, annotate, | Triage Stage:
decimal | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Adrian):

Submitted a pull to fix it: [https://github.com/django/django/pull/14168]

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

Django

unread,
Mar 23, 2021, 1:52:10 AM3/23/21
to django-...@googlegroups.com
#32585: Value() with DecimalField crashes on SQLite.
-------------------------------------+-------------------------------------
Reporter: Adrian Garcia | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite3, annotate, | Triage Stage: Accepted
decimal |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* needs_tests: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Thanks for the report, we should make `Value` inherit from
`SQLiteNumericMixin`.

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

Django

unread,
Mar 23, 2021, 3:40:28 PM3/23/21
to django-...@googlegroups.com
#32585: Value() with DecimalField crashes on SQLite.
-------------------------------------+-------------------------------------
Reporter: Adrian Garcia | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite3, annotate, | Triage Stage: Accepted
decimal |
Has patch: 0 | Needs documentation: 0

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

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


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

Django

unread,
Mar 28, 2021, 7:49:05 AM3/28/21
to django-...@googlegroups.com
#32585: Value() with DecimalField crashes on SQLite.
-------------------------------------+-------------------------------------
Reporter: Adrian Garcia | Owner: Hasan
| Ramezani
Type: Bug | Status: assigned

Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite3, annotate, | Triage Stage: Accepted
decimal |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* owner: nobody => Hasan Ramezani
* status: new => assigned


* has_patch: 0 => 1


Comment:

New [https://github.com/django/django/pull/14199 PR]

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

Django

unread,
Mar 28, 2021, 8:24:04 AM3/28/21
to django-...@googlegroups.com
#32585: Value() with DecimalField crashes on SQLite.
-------------------------------------+-------------------------------------
Reporter: Adrian Garcia | Owner: Manav
| Agarwal

Type: Bug | Status: assigned
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite3, annotate, | Triage Stage: Accepted
decimal |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Manav Agarwal):

* owner: Hasan Ramezani => Manav Agarwal


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

Django

unread,
Mar 28, 2021, 8:24:41 AM3/28/21
to django-...@googlegroups.com
#32585: Value() with DecimalField crashes on SQLite.
-------------------------------------+-------------------------------------
Reporter: Adrian Garcia | Owner: Hasan
| Ramezani

Type: Bug | Status: assigned
Component: Database layer | Version: 3.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: SQLite3, annotate, | Triage Stage: Accepted
decimal |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Manav Agarwal):

* owner: Manav Agarwal => Hasan Ramezani


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

Django

unread,
Mar 29, 2021, 1:29:35 AM3/29/21
to django-...@googlegroups.com
#32585: Value() with DecimalField crashes on SQLite.
-------------------------------------+-------------------------------------
Reporter: Adrian Garcia | Owner: Hasan
| Ramezani
Type: Bug | Status: closed

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

Keywords: SQLite3, annotate, | Triage Stage: Accepted
decimal |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"ed0cc52dc3b0dfebba8a38c12b6157a007309900" ed0cc52d]:
{{{
#!CommitTicketReference repository=""
revision="ed0cc52dc3b0dfebba8a38c12b6157a007309900"
Fixed #32585 -- Fixed Value() crash with DecimalField on SQLite.
}}}

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

Reply all
Reply to author
Forward
0 new messages