Tool doesn't work properly with postgresql-style table inheritance

Issue #334 resolved
Anonymous created an issue

I'm finding that the tool doesn't work properly with postgresql-style table inheritance.

Environment

  • SQLAlchemy-0.2.8[BR]
  • python 2.4.3[BR]
  • postgresql 8.1.4[BR]
  • ubuntu dapper drake[BR] [BR]

Setup for scenario (assuming a scott/tiger password combination)

$ createdb -U scott sample[BR] CREATE DATABASE[BR] $ psql -U scott sample[BR] ..[BR] sample=# create table node ( id int4 primary key, name varchar(20) NOT NULL );[BR] CREATE TABLE[BR] sample=# create table n_example (specialisation varchar(15)) inherits (node);[BR] CREATE TABLE[BR] [BR]

Scenario

$ python[BR] Python 2.4.3 (#2, Oct 6 2006, 07:52:30)[BR] 4.0.3 (Ubuntu 4.0.3-1ubuntu5) on linux2[BR] Type "help", "copyright", "credits" or "license" for more information.[BR]

from sqlalchemy.ext.sqlsoup import SqlSoup[BR] soup = SqlSoup('postgres://scott:tiger@localhost/sample')[BR] soup.node.select()[BR] [][BR] soup.n_example.select()[BR] Traceback (most recent call last):[BR] File "<stdin>", line 1, in ?[BR] File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line 1118, in select[BR] File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line 1084, in query[BR] File "build/bdist.linux-i686/egg/sqlalchemy/orm/query.py", line 19, in init[BR] File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line 166, in compile[BR] File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line 179, in _compile_all[BR] File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line 205, in _do_compile[BR] File "build/bdist.linux-i686/egg/sqlalchemy/orm/mapper.py", line 341, in _compile_tables[BR] sqlalchemy.exceptions.ArgumentError: Could not assemble any primary key columns for mapped table 'n_example'[BR] [BR]

I'd be interested in knowing when this bug is fixed and would appreciate if you could email craig et ahdore dotcm if it gets fixed.

Comments (2)

  1. Michael Bayer repo owner

    this regards supporting postgres inheritance which is not standard SQL, so i would consider this to be an enhancement. also, without knowing much about PG's inheritance, if it is not generally transparent at the SQL statement level it will be very very hard to implement this. also the specific example here regards reflection, so this would also require that PG's system catalogs provide the proper information about inheriting tables.

  2. Anonymous

    (original author: ants) This fails because postgres inheritance doesn't inherit primary key's. You have to add them by hand (and even then the parent table isn't guaranteed to have unique keys).

    create table node ( id int4 primary key, name varchar(20) NOT NULL );
    create table n_example (specialisation varchar(15), primary key (id)) inherits (node);
    
  3. Log in to comment