[sqlalchemy] Re: Mapping arbitrary selectables

2009-09-15 Thread Mike Conley
Submitted ticket #1542

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Mapping arbitrary selectables

2009-09-15 Thread Michael Bayer

Mike Conley wrote:
> 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'

that seems like a bug to me.   if you gave the mapper primary_key, and the
column is on the selectable, that error should never raise.   should not
matter what is present on the underlying Table objects.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---