On 7 October 2010 19:14, akaariai <[email protected]> wrote:
> Django doesn't expect the sequence name to be tablename_columname_seq,
> at least not in trunk. The last_insert_id method in backends/
> postgresql/operations.py uses select
> currval(pg_get_serial_sequence(tablename, columname)).
> pg_get_serial_sequence will return the correct sequence only if the
> sequence is owned by the tablename, columname combination. If you
> happen to have just one table per sequence, then issuing
> ALTER SEQUENCE sequencename OWNED BY tablename.columname;
> should fix the problem.

You can't necessarily do this with a legacy database, as other systems
also using that database expect the existing names.

I need to use my own backend because of posgresql's own
table-inheritance. Most tables in the db inherit from the same table
and inherits its primary key and the sequence for that primary key.
Then there are a few tables that inherits from a table that inherits
from the grandfather table that defines the primary key and its
sequence. So, I need to recursively discover the oldest ancestor of
each table and use the sequence of that ancestor.


HM

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en.

Reply via email to