Re: [Sqlalchemy-users] specifying the primary key for an arbitrary selectable

2006-02-02 Thread Michael Bayer
On Feb 2, 2006, at 7:23 PM, [EMAIL PROTECTED] wrote: is it bad to define a Table on what is actually a view in the backend? nah that should work fine, a view looks like a table to the outside (except you cant change it). as long as you specified primary key columns in your table def i

Re: [Sqlalchemy-users] specifying the primary key for an arbitrary selectable

2006-02-02 Thread daishi
On Feb 2, 2006, at 3:04 PM, Michael Bayer wrote: 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 sele

Re: [Sqlalchemy-users] specifying the primary key for an arbitrary selectable

2006-02-02 Thread Michael Bayer
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 fu

Re: [Sqlalchemy-users] specifying the primary key for an arbitrary selectable

2006-02-02 Thread daishi
On Feb 2, 2006, at 2:13 PM, Michael Bayer wrote: you want to set primary keys on a selectable ? selectables are supposed to very closely relate to SQL constructs. the mapper level is where you can define your not-quite-SQL constructs and how they map to your SQL constructs. since a SELECT st

Re: [Sqlalchemy-users] specifying the primary key for an arbitrary selectable

2006-02-02 Thread Michael Bayer
you want to set primary keys on a selectable ? selectables are supposed to very closely relate to SQL constructs. the mapper level is where you can define your not-quite-SQL constructs and how they map to your SQL constructs. since a SELECT statement in SQL doesnt have a primary key, im

[Sqlalchemy-users] specifying the primary key for an arbitrary selectable

2006-02-02 Thread daishi
hi, i'm trying to use an aliased selectable with a mapper, and the i'm getting an error that the selectable does not have a primary key. the error also says that i can specify the primary key to the mapper init, but i'd rather tell the selectable what its primary key is instead. i see that ther