On Feb 2, 2006, at 5:32 PM, [EMAIL PROTECTED] wrote:
1. mappers can be used to map against arbitrary
selects.
2. so i have some mapper factory functions which
take any selectable as arguments.
3. i expected that i could pass in "real" tables
or "abstract"/view-like selectables into my
factory functions transparently.
but maybe that's not the case? do my factory
functions need to be more aware of whether
they're getting a real table vs. an aliased
selectable?
well my answer was referring to defining a primary key on a select()
object. but the mapper() object allows you to specify a primary_key
on the mapper, as it relates to its selectable:
s = mytable.select(table.c.col1==5)
m = mapper(s, primary_key=[s.c.id])
so you can stick a straight table or an aliased selectable right into
a mapper the same way; its just if the selectable you are sending in
does not have a natural primary key (or the primary key that you
want), you have to tell the mapper what columns comprise the primary
key, which will override whatever it gets from the selectable.
All of the SQL objects, the three big ones Alias, Join, Select, (as
well as of course Table), do in fact have a primary_key attribute,
which in all cases is defined as the aggregate of all primary_key
columns found in the underlying selectables they represent.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users