I've found a better way of getting the correct sequence name on postgres

50 views
Skip to first unread message

Hanne Moa

unread,
Aug 19, 2016, 5:46:34 AM8/19/16
to django-d...@googlegroups.com
We needed to switch a table from using one sequence to another as the
first stage in merging two tables, and discovered that django can't
pick up the new sequence-name. Actually, it's the postgres-function
that the backend uses that is at fault.

Fortunately I found a way to introspect for the sequence name that
works in many more cases than the current use of
pg_get_serial_sequence: looking up the default value of a column in
"information_schema.columns", column "column_default". See ticket
#27090, https://code.djangoproject.com/ticket/27090 for some code.

While I'm scratching my immediate itch by updating the forked
postgres-backend we have to use anyway, switching away from
pg_get_serial_sequence would make life much easier and with fewer
surprises for everyone.

I will make a minimalistic, forked backend as a package (as soon as I
understand the style.SQL-stuff) but I do think that not using
pg_get_serial_sequence would be a general improvement for Django 1.11.
Reply all
Reply to author
Forward
0 new messages