#13179: last_insert_id method cannot find sequence
---------------------------------------------------+------------------------
Reporter: grangerp | Owner: nobody
Status: new | Milestone:
Component: Database layer (models, ORM) | Version: 1.1
Resolution: | Keywords:
Stage: Design decision needed | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
---------------------------------------------------+------------------------
Changes (by akaariai):
* stage: Accepted => Design decision needed
Comment:
This works only if the pk field is in fact serial or bigserial, but not
for columns of type[[BR]]
pk integer primary key default nextval('foobar_seq').
Tested on postgresql 8.4.3:
{{{
postgrs=# \d foobar
Table "public.foobar"
Column | Type | Modifiers
--------+---------+--------------------------------------------------
id | integer | not null default nextval('foobar_seq'::regclass)
Indexes:
"foobar_pkey" PRIMARY KEY, btree (id)
postgres=# select pg_get_serial_sequence('foobar', 'id');
pg_get_serial_sequence
------------------------
(1 row)
postgres=# \d foobar2
Table "public.foobar2"
Column | Type | Modifiers
--------+---------+------------------------------------------------------
id | integer | not null default nextval('foobar2_id_seq'::regclass)
postgres=# select pg_get_serial_sequence('foobar2', 'id');
pg_get_serial_sequence
------------------------
public.foobar2_id_seq
(1 row)
}}}
For any custom database schema using default nextval instead of serial
this would be a backwards incompatible change.
It is probably better to use a meta option (as in #13295) to allow
overriding the sequence name when the default doesn't work.
--
Ticket URL: <http://code.djangoproject.com/ticket/13179#comment:3>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.