[Django] #27452: Add Postgres serial field to contrib.postgres

68 views
Skip to first unread message

Django

unread,
Nov 6, 2016, 6:30:07 AM11/6/16
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
--------------------------------------------+------------------------
Reporter: Johannes Hoppe | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version: 1.10
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 |
--------------------------------------------+------------------------
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 a serial field. A
serial is a 4 byte integer with an implicit sequence. Ergo its and auto
increment field for none primary keys! Yeah!

**Usecase:** You could have a customer number, or invoice number in your
code. Usually it is a good idea to not use a natural primary key,
therefore reusing the pk as that number could be considered bad. Having a
separate field with a separate sequence solves this issue.

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

Django

unread,
Nov 6, 2016, 6:55:51 AM11/6/16
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
----------------------------------+--------------------------------------

Reporter: Johannes Hoppe | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version: 1.10
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
----------------------------------+--------------------------------------
Description changed by Burhan Khalid:

Old description:

> 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 a serial field. A
> serial is a 4 byte integer with an implicit sequence. Ergo its and auto
> increment field for none primary keys! Yeah!
>
> **Usecase:** You could have a customer number, or invoice number in your
> code. Usually it is a good idea to not use a natural primary key,
> therefore reusing the pk as that number could be considered bad. Having a
> separate field with a separate sequence solves this issue.

New description:

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.

--

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

Django

unread,
Nov 6, 2016, 12:13:07 PM11/6/16
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
----------------------------------+--------------------------------------

Reporter: Johannes Hoppe | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version: 1.10
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 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.

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

Django

unread,
Nov 6, 2016, 12:13:37 PM11/6/16
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner: Johannes
| Hoppe
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10
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 Johannes Hoppe):

* owner: (none) => Johannes Hoppe
* status: new => assigned


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

Django

unread,
Nov 8, 2016, 7:14:07 PM11/8/16
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner: Johannes
| Hoppe
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* stage: Unreviewed => Accepted


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

Django

unread,
Dec 22, 2018, 8:10:20 AM12/22/18
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner: Johannes
| Hoppe
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10

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 Johannes Hoppe):

* needs_better_patch: 1 => 0


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

Django

unread,
Dec 22, 2018, 10:56:03 AM12/22/18
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner: Johannes
| Hoppe
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1


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

Django

unread,
Sep 10, 2019, 8:17:28 PM9/10/19
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner: Johannes
| Hoppe
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10

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 Johannes Hoppe):

* needs_better_patch: 1 => 0


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

Django

unread,
Sep 11, 2019, 6:13:35 AM9/11/19
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner: Johannes
| Hoppe
Type: New feature | Status: assigned
Component: contrib.postgres | Version: 1.10

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1


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

Django

unread,
Sep 11, 2019, 6:34:01 AM9/11/19
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner: Johannes
| Hoppe
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* version: 1.10 => master


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

Django

unread,
Sep 12, 2019, 6:50:43 PM9/12/19
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner: Johannes
| Hoppe
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
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 Johannes Hoppe):

* needs_better_patch: 1 => 0


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

Django

unread,
Feb 5, 2020, 6:28:18 AM2/5/20
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner: Johannes
| Hoppe
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1

* needs_tests: 0 => 1


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

Django

unread,
May 21, 2020, 2:15:15 PM5/21/20
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner: Johannes
| Hoppe
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by InvalidInterrupt):

* cc: InvalidInterrupt (added)


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

Django

unread,
May 23, 2020, 11:44:55 AM5/23/20
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner: Johannes
| Hoppe
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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

--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:13>

Django

unread,
May 23, 2020, 2:27:43 PM5/23/20
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner: Johannes
| Hoppe
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by InvalidInterrupt):

Replying to [comment:13 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:14>

Django

unread,
May 23, 2020, 3:00:33 PM5/23/20
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
----------------------------------+------------------------------------

Reporter: Johannes Hoppe | Owner: (none)
Type: New feature | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by Claude Paroz):

* owner: Johannes Hoppe => (none)
* status: assigned => new


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:15>

Django

unread,
May 29, 2020, 3:42:12 PM5/29/20
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner:
| InvalidInterrupt

Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
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 InvalidInterrupt):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0


Comment:

[https://github.com/django/django/pull/12989 New PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:17>

Django

unread,
Sep 23, 2020, 5:16:16 AM9/23/20
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner:
| InvalidInterrupt
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:18>

Django

unread,
Oct 20, 2020, 11:57:37 PM10/20/20
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Hoppe | Owner:
| InvalidInterrupt
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
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 InvalidInterrupt):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0


Comment:

[https://github.com/django/django/pull/13580 New PR for Default
Expression]

--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:19>

Django

unread,
Nov 14, 2020, 12:22:00 PM11/14/20
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner:

| InvalidInterrupt
Type: New feature | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

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

* needs_docs: 0 => 1


* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:21>

Django

unread,
Jul 23, 2022, 5:23:34 AM7/23/22
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner:
| InvalidInterrupt
Type: New feature | Status: assigned
Component: contrib.postgres | Version: dev

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by Claude Paroz):

Does this still make sense now that Django is using identity columns for
`*AutoField`s?

--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:22>

Django

unread,
Nov 8, 2022, 11:23:58 AM11/8/22
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner:
| InvalidInterrupt
Type: New feature | Status: assigned
Component: contrib.postgres | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0

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

Comment (by Simon Charette):

Claude, yes I think that the move to identity columns on Postgres made
this feature even more desirable (e.g. #34131).

--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:23>

Django

unread,
Feb 20, 2024, 11:53:09 PMFeb 20
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner:
| InvalidInterrupt
Type: New feature | Status: assigned
Component: contrib.postgres | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):

FWIW [https://forum.djangoproject.com/t/django-4-2-is-a-2nd-autofield-
like-field-on-a-model-possible/28278/4 someone was able to implement] an
`IdentityField` which is kind of the equivalent of `GeneratedField` if it
supported `AS IDENTITY`. It's not the equivalent of `SerialField` though
but it demonstrates that all the pieces are there to implement it based on
`db_returning` and `pre_save` returning a `Default` expression.
--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:24>

Django

unread,
May 6, 2024, 12:12:25 PMMay 6
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: assigned
Component: contrib.postgres | Version: dev
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 Csirmaz Bendegúz):

* needs_docs: 1 => 0
* needs_tests: 1 => 0
* owner: InvalidInterrupt => Csirmaz Bendegúz

Comment:

I'm going to push this forward because we need an alternative to #8576
(https://code.djangoproject.com/ticket/8576#comment:10). Please review my
PR (https://github.com/django/django/pull/18123).
--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:25>

Django

unread,
May 27, 2024, 6:51:23 AMMay 27
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: assigned
Component: contrib.postgres | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:26>

Django

unread,
May 31, 2024, 3:53:58 AMMay 31
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: assigned
Component: contrib.postgres | Version: dev
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 Sarah Boyce):

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:27>

Django

unread,
Jun 8, 2024, 2:54:33 AMJun 8
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: assigned
Component: contrib.postgres | Version: dev
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
-------------------------------------+-------------------------------------
Comment (by Florian Apolloner):

Hi folks, I am wondering if we really want & need something like this in
Django. What are the arguments that this has to be in Django as opposed to
a third party library. The issue exists since 8 years with little to no
comments so I would argue that using multiple serial fields on a model or
having explicit access to a serial field is not a feature that is needed
often. So even if this is in contrib I kinda wonder if we have to support
every postgresql feature out there.
--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:28>

Django

unread,
Jun 8, 2024, 2:55:35 AMJun 8
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: assigned
Component: contrib.postgres | Version: dev
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 Florian Apolloner):

* cc: Florian Apolloner (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:29>

Django

unread,
Jun 18, 2024, 7:46:51 AM (11 days ago) Jun 18
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: assigned
Component: contrib.postgres | Version: dev
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
-------------------------------------+-------------------------------------
Comment (by Csirmaz Bendegúz):

Replying to [comment:28 Florian Apolloner]:
> Hi folks, I am wondering if we really want & need something like this in
Django. What are the arguments that this has to be in Django as opposed to
a third party library. The issue exists since 8 years with little to no
comments so I would argue that using multiple serial fields on a model or
having explicit access to a serial field is not a feature that is needed
often. So even if this is suggested for contrib I kinda wonder if we have
to support every postgresql feature out there.

My goal with this one is to have a field that can be used as a ''surrogate
key'' in composite primary keys
([https://code.djangoproject.com/ticket/373 #373]), when/if that feature
lands.

If we can't have AutoFields in composite primary keys
([https://code.djangoproject.com/ticket/8576#comment:10 #8576]), then it
would be nice to have SerialFields at least.
--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:30>

Django

unread,
Jun 19, 2024, 1:40:10 AM (11 days ago) Jun 19
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: assigned
Component: contrib.postgres | Version: dev
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 Csirmaz Bendegúz):

* cc: Csirmaz Bendegúz (added)

--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:31>

Django

unread,
Jun 25, 2024, 2:20:44 PM (4 days ago) Jun 25
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: assigned
Component: contrib.postgres | Version: dev
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
-------------------------------------+-------------------------------------
Comment (by Florian Apolloner):

To be honest I'd be slightly in favor of removing the existing limitations
of AutoFields where databases can support it (if we are able to decide
that it makes sense semantically at least). Adding a new field that
basically does the same thing as an existing field kinda feels wrong.
Granted, an explicit Serial/IdentityField would allow to specifiy more
options (like adjusting the sequence name), but I am not sure if that
would be a common enough usecase to add it to django itself.
--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:32>

Django

unread,
Jun 26, 2024, 1:02:34 PM (3 days ago) Jun 26
to django-...@googlegroups.com
#27452: Add Postgres serial field to contrib.postgres
-------------------------------------+-------------------------------------
Reporter: Johannes Maron | Owner: Csirmaz
| Bendegúz
Type: New feature | Status: assigned
Component: contrib.postgres | Version: dev
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
-------------------------------------+-------------------------------------
Comment (by Csirmaz Bendegúz):

Replying to [comment:32 Florian Apolloner]:
> To be honest I'd be slightly in favor of removing the existing
limitations of AutoFields where databases can support it (if we are able
to decide that it makes sense semantically at least). Adding a new field
that basically does the same thing as an existing field kinda feels wrong.
Granted, an explicit Serial/IdentityField would allow to specifiy more
options (like adjusting the sequence name), but I am not sure if that
would be a common enough usecase to add it to django itself.

I was thinking the same thing initially, but this ticket was already
Accepted, while [https://code.djangoproject.com/ticket/8576 #8576]
received a lot of push back and was closed as wontfix.

IMO, another legit use-case is an "order column" - an auto-generated
sequence that can be changed by the users. Semantically, it makes more
sense to use SERIAL over IDENTITY for this.
--
Ticket URL: <https://code.djangoproject.com/ticket/27452#comment:33>
Reply all
Reply to author
Forward
0 new messages