mirror of
https://github.com/django/django.git
synced 2024-12-29 04:26:28 +00:00
[5.0.x] Fixed #35032 -- Corrected Char32UUIDField implementation in 5.0 release notes.
This fixes Char32UUIDField implementation in 5.0 release notes causing records with UUIDFields created using pre-Django 5.0 and CHAR(32) not being able to be saved anymore after upgrading and keeping the CHAR(32) columns. Regression in7cd187a5ba
. Backport ofe72b2826ff
from main
This commit is contained in:
parent
8b0710cfc9
commit
636d701ded
@ -508,6 +508,12 @@ Django < 5.0 should be replaced with a ``UUIDField`` subclass backed by
|
|||||||
def db_type(self, connection):
|
def db_type(self, connection):
|
||||||
return "char(32)"
|
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::
|
For example::
|
||||||
|
|
||||||
class MyModel(models.Model):
|
class MyModel(models.Model):
|
||||||
@ -516,8 +522,7 @@ For example::
|
|||||||
Should become::
|
Should become::
|
||||||
|
|
||||||
class Char32UUIDField(models.UUIDField):
|
class Char32UUIDField(models.UUIDField):
|
||||||
def db_type(self, connection):
|
...
|
||||||
return "char(32)"
|
|
||||||
|
|
||||||
|
|
||||||
class MyModel(models.Model):
|
class MyModel(models.Model):
|
||||||
|
Loading…
Reference in New Issue
Block a user