ive identified this specific issue and fixed it; it has to do with overriding primary key columns that are reflected (the PrimaryKeyConstraint got two versions of the same column in it, one of which was not in the table's main collection of columns, which is an invalid state). it is fixed in revision 1922.
also with your example below, you should probably have "primary_key=True" set on your overridden "products_id" column since it is a primary key in the original table (and you cannot map to a table that does not have a primary key). On Sep 26, 2006, at 7:32 AM, Matias Hermanrud Fjeld wrote: > Hello. > > I'm working with OSCommerce, which has a poorly defined schema. There > are no foreignkey constraints, so i have redefined the relevant > columns > in SA (see below). > > I add some rows, and when flushing i get the following error: > > sqlalchemy.exceptions.InvalidRequestError: Column > 'products_description.products_id' is not available, due to > conflicting > property 'products_id':ColumnProperty > (['products_description.products_id']) > > What are the usual causes of this type of error? > > Here is the code loading the tables and setting up mappings: > > [snip Product and Description class definitions] > > p_d_table = sa.Table('products_description', meta, > sa.Column('products_id', sa.Integer, > sa.ForeignKey > ('products.products_id')), > autoload=True) > > sa.mapper(Description, p_d_table) > > p_table = sa.Table('products', meta, > [snip manufacturers_id column] > autoload=True) > sa.mapper( > Product, p_table, > properties=dict( > descriptions=sa.relation(Description), > [snip categories relation] > ) > ) > > Here are the relevant tables: > > mysql> describe products; > +-------------------------+---------------+------+-----+--------- > +----------------+ > | Field | Type | Null | Key | Default | > Extra | > +-------------------------+---------------+------+-----+--------- > +----------------+ > | products_id | int(11) | NO | PRI | NULL | > auto_increment | > | products_quantity | int(4) | NO | | > | | > | products_model | varchar(30) | YES | | NULL > | | > | products_image | varchar(64) | YES | | NULL > | | > | products_price | decimal(15,4) | NO | | > | | > | products_date_added | datetime | NO | MUL | > | | > | products_last_modified | datetime | YES | | NULL > | | > | products_date_available | datetime | YES | | NULL > | | > | products_weight | decimal(5,2) | NO | | > | | > | products_status | tinyint(1) | NO | | > | | > | products_tax_class_id | int(11) | NO | | > | | > | manufacturers_id | int(11) | YES | | NULL > | | > | products_ordered | int(11) | NO | | 0 > | | > | products_distributor | varchar(20) | NO | | > | | > +-------------------------+---------------+------+-----+--------- > +----------------+ > > mysql> describe products_description; > +----------------------+--------------+------+-----+--------- > +----------------+ > | Field | Type | Null | Key | Default | > Extra | > +----------------------+--------------+------+-----+--------- > +----------------+ > | products_id | int(11) | NO | PRI | NULL | > auto_increment | > | language_id | int(11) | NO | PRI | 1 > | | > | products_name | varchar(64) | NO | MUL | > | | > | products_description | text | YES | | NULL > | | > | products_url | varchar(255) | YES | | NULL > | | > | products_viewed | int(5) | YES | | 0 > | | > +----------------------+--------------+------+-----+--------- > +----------------+ > > > I'm new to SA, so if I'm missing something obvious, please bear > with me. > > -- > Matias Hermanrud Fjeld > Copyleft Solutions AS > > > ---------------------------------------------------------------------- > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys -- and earn > cash > http://www.techsay.com/default.php? > page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Sqlalchemy-users mailing list > Sqlalchemy-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users