Opened 4 years ago

Last modified 8 hours ago

#27452 assigned New feature

Add Postgres serial field to contrib.postgres

Reported by: Johannes Hoppe Owned by: InvalidInterrupt
Component: contrib.postgres Version: master
Severity: Normal Keywords:
Cc: info@…, InvalidInterrupt Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by Burhan Khalid)

Since we have the beautiful contrib.postgres package now, we can add a couple more Postgres specific fields, that are not supported by MySQL but handy to all the Postgres fan boys.

That being said, I guess it's a good idea to start with Serial.

The PostgreSQL documentation: https://www.postgresql.org/docs/9.1/static/datatype-numeric.html describes the field as follows:

The data types serial and bigserial are not true types, but merely a notational convenience for creating unique identifier columns (similar to the AUTO_INCREMENT property supported by some other databases).

Use Cases:

  1. Anywhere an automatic incrementing value is required, but a primary key is often (mis)used.
  2. Providing additional (user controlled) auto-incrementing values.

The primary benefit is that is isolates the primary key for the sole use of maintaining referential integrity.

Change History (18)

comment:1 Changed 4 years ago by Burhan Khalid

Description: modified (diff)

comment:2 Changed 4 years ago by Johannes Hoppe

I opened a PR with an implementation that I am already using somewhere. It added a couple of tests and documentation too.
I guess this is a good starting point for a discussion.

Last edited 4 years ago by Tim Graham (previous) (diff)

comment:3 Changed 4 years ago by Johannes Hoppe

Owner: set to Johannes Hoppe
Status: newassigned

comment:4 Changed 4 years ago by Tim Graham

Has patch: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

comment:5 Changed 21 months ago by Johannes Hoppe

Patch needs improvement: unset

comment:6 Changed 21 months ago by Simon Charette

Patch needs improvement: set

comment:7 Changed 13 months ago by Johannes Hoppe

Patch needs improvement: unset

comment:8 Changed 13 months ago by Nick Pope

Patch needs improvement: set

comment:9 Changed 13 months ago by Nick Pope

Version: 1.10master

comment:10 Changed 13 months ago by Johannes Hoppe

Patch needs improvement: unset

comment:11 Changed 8 months ago by felixxm

Needs tests: set
Patch needs improvement: set

comment:12 Changed 4 months ago by InvalidInterrupt

Cc: InvalidInterrupt added

comment:13 Changed 4 months ago by Johannes Hoppe

I closed my PR for now, due to a lack of interest. Since Django does support returning values since v3.0 everyone who needs such a field can build it. Yet, I don't have the time get the feature into Django for now.

comment:14 in reply to:  13 Changed 4 months ago by InvalidInterrupt

Replying to Johannes Hoppe:

I closed my PR for now, due to a lack of interest. Since Django does support returning values since v3.0 everyone who needs such a field can build it. Yet, I don't have the time get the feature into Django for now.

Do you mind if I continue working on this using your branch? Handling sequence resets after loading fixtures will require changes to the DB backend.

comment:15 Changed 4 months ago by Claude Paroz

Owner: Johannes Hoppe deleted
Status: assignednew

Latest comment from Johannes is clearly an invitation to help :-)

comment:16 Changed 4 months ago by InvalidInterrupt

Owner: set to InvalidInterrupt
Status: newassigned

comment:17 Changed 4 months ago by InvalidInterrupt

Needs tests: unset
Patch needs improvement: unset

comment:18 Changed 8 hours ago by felixxm

Needs tests: set
Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top