When mapping an arbitrary selectable, does mapper's primary_key argument
need to be a primary key in the base table?
Using 0.5.6, but I seem to remember same behavior in earlier versions.

This works and does not generate any errors:

t1 = Table('t1', meta, Column('foo', Integer, primary_key=True))
s1 = select([t1.c.foo])
class One(object): pass
mapper(One, s1, primary_key=[s1.c.foo])    ## Note: also OK without pk
argument

This raises an exception complaining about the primary key

t2 = Table('t2', meta, Column('bar', Integer))
s2 = select([t2.c.bar])
class Two(object): pass
mapper(Two, s2, primary_key=[s2.c.bar])  # same error using [t2.c.bar]

ArgumentError: Mapper Mapper|Two|%(31476816 anon)s could not assemble any
primary key columns for mapped table '%(31476816 anon)s'



-- 
Mike Conley

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to