[Django] #28439: When() [on MySQL] does not work with models using UUID as primary key

5 views
Skip to first unread message

Django

unread,
Jul 27, 2017, 1:54:03 AM7/27/17
to django-...@googlegroups.com
#28439: When() [on MySQL] does not work with models using UUID as primary key
-------------------------------------+-------------------------------------
Reporter: Dominik | Owner: nobody
Kozaczko |
Type: Bug | Status: new
Component: Database | Version: 1.11
layer (models, ORM) |
Severity: Release | Keywords: when,
blocker |
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I have a strange issue with `When()` and models using UUID as their pk.

I prepared example project here: https://github.com/dekoza/djanbug

The `example.views.myview` includes code ported from the app I'm currently
developing - I have several models using UUIDs as their PK and I need to
do some annotations an aggregations with some specific cases handled with
`Case()/When()` combo.

Even though the db is empty on the example, the view crashes that `'1' is
not a valid UUID.` and the only '1' is the one in `When()`

I've also encountered issues with `Count('*', distinct=True)` but right
now I'm trying to reproduce it on the example and will post another ticket
when I'm done.

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

Django

unread,
Jul 27, 2017, 1:57:44 AM7/27/17
to django-...@googlegroups.com
#28439: When() [on MySQL] does not work with models using UUID as primary key
-------------------------------------+-------------------------------------
Reporter: Dominik Kozaczko | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: when, | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Dominik Kozaczko:

Old description:

> I have a strange issue with `When()` and models using UUID as their pk.
>
> I prepared example project here: https://github.com/dekoza/djanbug
>
> The `example.views.myview` includes code ported from the app I'm
> currently developing - I have several models using UUIDs as their PK and
> I need to do some annotations an aggregations with some specific cases
> handled with `Case()/When()` combo.
>
> Even though the db is empty on the example, the view crashes that `'1' is
> not a valid UUID.` and the only '1' is the one in `When()`
>
> I've also encountered issues with `Count('*', distinct=True)` but right
> now I'm trying to reproduce it on the example and will post another
> ticket when I'm done.

New description:

I have a strange issue with `When()` and models using UUID as their pk.

The DB is MySQL 5.6.23 but I've encountered it also on the newest 5.7
version (which is a pain but it's a different story).

I prepared example project here: https://github.com/dekoza/djanbug

The `example.views.myview` includes code ported from the app I'm currently
developing - I have several models using UUIDs as their PK and I need to
do some annotations an aggregations with some specific cases handled with
`Case()/When()` combo.

Even though the db is empty on the example, the view crashes that `'1' is
not a valid UUID.` and the only '1' is the one in `When()`

I've also encountered issues with `Count('*', distinct=True)` but right
now I'm trying to reproduce it on the example and will post another ticket
when I'm done.

--

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

Django

unread,
Jul 27, 2017, 8:22:00 AM7/27/17
to django-...@googlegroups.com
#28439: When() crashes with ValidationError with models using UUID as primary key
-------------------------------------+-------------------------------------
Reporter: Dominik Kozaczko | Owner: nobody
Type: Bug | Status: new

Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Normal | Resolution:
Keywords: when, | 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
* severity: Release blocker => Normal


Comment:

I didn't verify that the issue isn't a mistake in queryset construction,
but even if so, the error message could be better. It would be useful to
try to construct a more minimal example that reproduces the issue, ideally
as a test for Django's test suite. The issue doesn't seem limited to
MySQL; the same error happens with SQLite.

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

Django

unread,
Aug 8, 2017, 2:12:57 PM8/8/17
to django-...@googlegroups.com
#28439: When() crashes with ValidationError with models using UUID as primary key
-------------------------------------+-------------------------------------
Reporter: Dominik Kozaczko | Owner: Srinivas
| Reddy Thatiparthy
Type: Bug | Status: assigned

Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Normal | Resolution:
Keywords: when, | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Srinivas Reddy Thatiparthy):

* owner: nobody => Srinivas Reddy Thatiparthy
* status: new => assigned


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

Django

unread,
Jul 18, 2019, 8:24:14 AM7/18/19
to django-...@googlegroups.com
#28439: When() crashes with ValidationError with models using UUID as primary key
-------------------------------------+-------------------------------------

Reporter: Dominik Kozaczko | Owner: Srinivas
| Reddy Thatiparthy
Type: Bug | Status: closed
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: when, | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

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

* status: assigned => closed
* version: 1.11 => 2.2
* resolution: => fixed


Comment:

Fixed by 83c7096f2a84450957615ef52ffed0bee5f72606.

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

Reply all
Reply to author
Forward
0 new messages