mapping arbitrary selectable does not use primary_key argument
Issue #1542
resolved
If a selectable does not contain a column that is primary key in a base table, then cannot use that selectable in a mapper.
This code
t2 = Table('t2', meta, Column('bar', Integer))
s2 = select([t2.c.bar](t2.c.bar))
class Two(object): pass
mapper(Two, s2, primary_key=[s2.c.bar](s2.c.bar)) # same error using [t2.c.bar](t2.c.bar)
raises exception
argumentError : Mapper Mapper|Two|%(31476816 anon)s could not assemble any primary key columns for mapped table '%(31476816 anon)s'
When 'bar' is a primary key for table 't2', the mapper is successful.
Comments (2)
-
repo owner -
repo owner - removed milestone
Removing milestone: 0.6.0 (automated comment)
- Log in to comment
You missed a warning which states:
the only rationale for the alias() is that databases like PG and MySQL require it. so removed the ambiguity here by raising the warning to an error in cf6c66e70ea406a27c4a8d5b79f9c629a62320fc.