Opened 11 years ago

Last modified 12 days ago

#17337 new Bug

[nonrel] Support for non-integer AutoFields

Reported by: Jonas H. Owned by:
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: nonrel
Cc: Brian Helba, raydeal Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


(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.

Attachments (1)

nonint-autoid.patch (3.7 KB) - added by Jonas H. 11 years ago.

Download all attachments as: .zip

Change History (13)

Changed 11 years ago by Jonas H.

Attachment: nonint-autoid.patch added

comment:1 Changed 11 years ago by Carl Meyer

Triage Stage: UnreviewedAccepted

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.

comment:2 Changed 11 years ago by Russell Keith-Magee

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.

comment:3 Changed 11 years ago by Jonas H.

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?

comment:4 Changed 11 years ago by Aymeric Augustin

Type: UncategorizedBug

Two tickets (#17214, #17122) were recently reported about problems in the admin with models using non-integer primary keys. A quick search for "primary_key" turns up several problems with non-integer primary keys, but I think these should be handled separately.

I'm updating the title to reflect that this ticket is about non-integer automatic primary keys.

Last edited 11 years ago by Aymeric Augustin (previous) (diff)

comment:5 Changed 11 years ago by Aymeric Augustin

Summary: [nonrel] Support for non-integer primary keys[nonrel] Support for non-integer automatic primary keys

comment:6 Changed 9 years ago by Tim Graham

Patch needs improvement: set

comment:7 Changed 8 years ago by Collin Anderson

Summary: [nonrel] Support for non-integer automatic primary keys[nonrel] Support for non-integer AutoFields

comment:8 Changed 3 years ago by Nick Pope

This is partially addressed by 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.

comment:9 Changed 3 years ago by Mariusz Felisiak <felisiak.mariusz@…>

In 21e5594:

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.

comment:10 Changed 11 months ago by Brian Helba

Cc: Brian Helba added

comment:11 Changed 6 months ago by raydeal

Owner: changed from nobody to raydeal
Status: newassigned

comment:12 Changed 12 days ago by raydeal

Cc: raydeal added
Owner: raydeal deleted
Status: assignednew
Note: See TracTickets for help on using tickets.
Back to Top