#35032: Cannot save record with UUID field after migrating existing UUIDField
created in Django < 5.0
-------------------------------------+-------------------------------------
Reporter: Emanuel Andrecut | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 5.0
(models, ORM) |
Severity: Release blocker | Resolution:
Keywords: uuid, mariadb, | Triage Stage: Accepted
UUIDField, DataError |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* cc: raydeal (added)
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
Comment:
Thanks for the report! Sounds reasonable, I'm not sure if we want to add
workarounds to the Django itself. What do you think about updating release
notes? For example:
{{{#!diff
diff --git a/docs/releases/5.0.txt b/docs/releases/5.0.txt
index 4c86337b74..87fda8d866 100644
--- a/docs/releases/5.0.txt
+++ b/docs/releases/5.0.txt
@@ -508,6 +508,13 @@ Django < 5.0 should be replaced with a ``UUIDField``
subclass backed by
def db_type(self, connection):
return "char(32)"
+
+ def get_db_prep_value(self, value, connection, prepared=False):
+ value = super().get_db_prep_value(value, connection,
prepared)
+ if value is not None:
+ value = value.hex
+ return value
+
For example::
class MyModel(models.Model):
@@ -516,8 +523,7 @@ For example::
Should become::
class Char32UUIDField(models.UUIDField):
- def db_type(self, connection):
- return "char(32)"
+ ...
class MyModel(models.Model):
}}}
Regression in 7cd187a5ba58d7769039f487faeb9a5a2ff05540.
--
Ticket URL: <https://code.djangoproject.com/ticket/35032#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018c64ac35d7-b5147ba5-5e19-46e7-b73e-1ee2e93defab-000000%40eu-central-1.amazonses.com.