[Django] #17337: [nonrel] Support for non-integer primary keys

13 views
Skip to first unread message

Django

unread,
Dec 3, 2011, 4:59:58 PM12/3/11
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer primary keys
----------------------------------------------+--------------------
Reporter: jonash | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer (models, ORM) | Version: SVN
Severity: Normal | Keywords: nonrel
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
(This patch is part of the changes made to the inofficial fork "Django-
nonrel" which adds basic support for non-relational databases.)

This patch adds basic support for non-integer primary keys. It works by
not restricting primary keys to `int` and factoring out pk validation/type
conversion into the backend.

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

Django

unread,
Dec 8, 2011, 6:52:39 PM12/8/11
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer primary keys
-------------------------------------+-------------------------------------
Reporter: jonash | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: SVN
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: nonrel | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by carljm):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

Accepting the ticket, as support for non-integer auto-fields is certainly
desirable. I believe there's a different implementation of it in Alex
Gaynor's 2010 GSoC code - I don't know which implementation is preferable.

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

Django

unread,
Dec 8, 2011, 7:42:13 PM12/8/11
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer primary keys
-------------------------------------+-------------------------------------
Reporter: jonash | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: SVN
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: nonrel | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by russellm):

IIRC, Alex's GSoC code punted on this issue (or, at least, had code that
wasn't suitable for trunk), because we couldn't come up with a way to
introduce it without introducing backwards incompatibilities. I seem to
recall there were a bunch of places in the code that assumed that
AutoFields were integers; however, it's been a while, so I might be mis-
remembering.

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

Django

unread,
Dec 8, 2011, 7:48:07 PM12/8/11
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer primary keys
-------------------------------------+-------------------------------------
Reporter: jonash | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: SVN
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: nonrel | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by jonash):

A few contrib apps assume PKs to be integers and also it gets tricky when
it comes to testing with fixtures. Should we address all these issues at
once or fix them bit by bit in multiple tickets?

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

Django

unread,
Dec 9, 2011, 6:20:25 AM12/9/11
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer primary keys
-------------------------------------+-------------------------------------
Reporter: jonash | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: SVN
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: nonrel | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* type: Uncategorized => Bug


Comment:

Two tickets (#17214, #17122) were recently reported about problems in the
admin with models using non-integer primary keys. A quick
[https://code.djangoproject.com/search?q=primary_key&noquickjump=1&ticket=on
search for "primary_key"] turns up lots of other problems with non-integer
primary keys. Clearly people are trying to use them, and as far as I can
see, [https://docs.djangoproject.com/en/dev/ref/models/fields/#primary-key
the docs] don't forbid it.

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

Django

unread,
Dec 9, 2011, 6:27:47 AM12/9/11
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer automatic primary keys
-------------------------------------+-------------------------------------
Reporter: jonash | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: SVN
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: nonrel | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

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

Django

unread,
Aug 29, 2013, 11:29:10 AM8/29/13
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer automatic primary keys
-------------------------------------+-------------------------------------
Reporter: jonash | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master

(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: nonrel | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1

Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: 0 => 1


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

Django

unread,
Mar 13, 2015, 11:42:58 PM3/13/15
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer AutoFields
-------------------------------------+-------------------------------------
Reporter: jonash | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: nonrel | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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

Django

unread,
Jul 26, 2019, 7:15:33 PM7/26/19
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer AutoFields
-------------------------------------+-------------------------------------
Reporter: Jonas H. | Owner: nobody

Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: nonrel | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Nick Pope):

This is partially addressed by
[https://github.com/django/django/pull/10680 PR] for #29979, but will
further depend on #470 for default values for non-integer fields as well
as #24042 for replacing `isinstance(..., AutoField)` checks.

--
Ticket URL: <https://code.djangoproject.com/ticket/17337#comment:8>

Django

unread,
Aug 20, 2019, 4:37:06 AM8/20/19
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer AutoFields
-------------------------------------+-------------------------------------
Reporter: Jonas H. | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: nonrel | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"21e559495b8255bba1e8a4429cd083246ab90457" 21e5594]:
{{{
#!CommitTicketReference repository=""
revision="21e559495b8255bba1e8a4429cd083246ab90457"
Fixed #29979, Refs #17337 -- Extracted AutoField field logic into a mixin
and refactored AutoFields.

This reduces duplication by allowing AutoField, BigAutoField and
SmallAutoField to inherit from IntegerField, BigIntegerField and
SmallIntegerField respectively. Doing so also allows for enabling the
max_length warning check and minimum/maximum value validation for auto
fields, as well as providing a mixin that can be used for other possible
future auto field types such as a theoretical UUIDAutoField.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/17337#comment:9>

Django

unread,
Nov 8, 2021, 8:06:53 PM11/8/21
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer AutoFields
-------------------------------------+-------------------------------------
Reporter: Jonas H. | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: dev

(models, ORM) |
Severity: Normal | Resolution:
Keywords: nonrel | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Brian Helba):

* cc: Brian Helba (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/17337#comment:10>

Django

unread,
Apr 21, 2022, 4:30:38 AM4/21/22
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer AutoFields
-------------------------------------+-------------------------------------
Reporter: Jonas H. | Owner: raydeal
Type: Bug | Status: assigned

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: nonrel | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by raydeal):

* owner: nobody => raydeal
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/17337#comment:11>

Django

unread,
Sep 23, 2022, 2:02:09 PM9/23/22
to django-...@googlegroups.com
#17337: [nonrel] Support for non-integer AutoFields
-------------------------------------+-------------------------------------
Reporter: Jonas H. | Owner: (none)
Type: Bug | Status: new

Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: nonrel | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by raydeal):

* cc: raydeal (added)
* owner: raydeal => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/17337#comment:12>

Reply all
Reply to author
Forward
0 new messages