Opened 7 years ago

Closed 5 years ago

#28439 closed Bug (fixed)

When() crashes with ValidationError with models using UUID as primary key

Reported by: Dominik Kozaczko Owned by: Srinivas Reddy Thatiparthy
Component: Database layer (models, ORM) Version: 2.2
Severity: Normal Keywords: when,
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Dominik Kozaczko)

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.

Change History (4)

comment:1 by Dominik Kozaczko, 7 years ago

Description: modified (diff)

comment:2 by Tim Graham, 7 years ago

Severity: Release blockerNormal
Summary: When() [on MySQL] does not work with models using UUID as primary keyWhen() crashes with ValidationError with models using UUID as primary key
Triage Stage: UnreviewedAccepted

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.

comment:3 by Srinivas Reddy Thatiparthy, 7 years ago

Owner: changed from nobody to Srinivas Reddy Thatiparthy
Status: newassigned

comment:4 by Mariusz Felisiak, 5 years ago

Resolution: fixed
Status: assignedclosed
Version: 1.112.2
Note: See TracTickets for help on using tickets.
Back to Top