[Django] #29869: UUIDField to_python should convert int values

59 views
Skip to first unread message

Django

unread,
Oct 19, 2018, 9:01:37 AM10/19/18
to django-...@googlegroups.com
#29869: UUIDField to_python should convert int values
-----------------------------------------+------------------------
Reporter: thenewguy | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
It would be handy if UUIDField.to_python() could handle integer values.
This has practical application when using generic foreign keys in a
project that mixes auto fields and uuid primary keys. The generic id
field could be set to a BigIntegerField and then could point to uuid or
integer primary keys

https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L2320

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

Django

unread,
Oct 20, 2018, 8:27:46 PM10/20/18
to django-...@googlegroups.com
#29869: UUIDField.to_python() should convert int values
-------------------------------------+-------------------------------------
Reporter: thenewguy | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* component: Uncategorized => Database layer (models, ORM)
* type: Uncategorized => Cleanup/optimization


Comment:

How would the conversion work?

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

Django

unread,
Oct 20, 2018, 8:30:35 PM10/20/18
to django-...@googlegroups.com
#29869: UUIDField.to_python() should convert int values
-------------------------------------+-------------------------------------
Reporter: thenewguy | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by thenewguy):

uuid.UUID(int=value) worked for me but I haven't tested any cases yet

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

Django

unread,
Oct 20, 2018, 9:38:44 PM10/20/18
to django-...@googlegroups.com
#29869: UUIDField.to_python() should convert int values
-------------------------------------+-------------------------------------
Reporter: thenewguy | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* stage: Unreviewed => Accepted


Comment:

Accepting on the basis that I could see it being useful when migrating a
project from sequence based to uuid primary keys.

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

Django

unread,
Oct 24, 2018, 4:56:00 PM10/24/18
to django-...@googlegroups.com
#29869: UUIDField.to_python() should convert int values
-------------------------------------+-------------------------------------
Reporter: thenewguy | Owner: Sanyam
Type: | Khurana
Cleanup/optimization | Status: assigned

Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sanyam Khurana):

* status: new => assigned
* owner: nobody => Sanyam Khurana


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

Django

unread,
Oct 24, 2018, 4:58:11 PM10/24/18
to django-...@googlegroups.com
#29869: UUIDField.to_python() should convert int values
-------------------------------------+-------------------------------------
Reporter: thenewguy | Owner: Sanyam
Type: | Khurana
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* has_patch: 0 => 1


Comment:

I've added a patch for this here:
https://github.com/django/django/pull/10557

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

Django

unread,
Oct 24, 2018, 5:55:44 PM10/24/18
to django-...@googlegroups.com
#29869: UUIDField.to_python() should convert int values
-------------------------------------+-------------------------------------
Reporter: thenewguy | Owner: Sanyam
Type: | Khurana
Cleanup/optimization | Status: assigned
Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

* stage: Accepted => Ready for checkin


Comment:

Marking as RFC given I'm not sure this is worth a mention in the release
notes.

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

Django

unread,
Oct 24, 2018, 8:45:15 PM10/24/18
to django-...@googlegroups.com
#29869: UUIDField.to_python() should convert int values
-------------------------------------+-------------------------------------
Reporter: thenewguy | Owner: Sanyam
Type: | Khurana
Cleanup/optimization | Status: closed

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

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"83c7096f2a84450957615ef52ffed0bee5f72606" 83c7096f]:
{{{
#!CommitTicketReference repository=""
revision="83c7096f2a84450957615ef52ffed0bee5f72606"
Fixed #29869 -- Made UUIDField.to_python() convert integers.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29869#comment:7>

Reply all
Reply to author
Forward
0 new messages