[sqlalchemy] Re: Mapping and querying multiple levels of foreign key'd tables

2008-03-05 Thread Christoph Haas
On Wed, Mar 05, 2008 at 08:31:12AM +0100, Christoph Haas wrote: Basically I have three tables like 'companies', 'departments' and 'employees'. I have already set up foreign keys and gave all of them one-to-many relationships. So a company has several departments. And each department has

[sqlalchemy] Re: Integrating the ORM with Trellis

2008-03-05 Thread Michael Bayer
On Mar 4, 2008, at 7:27 PM, Phillip J. Eby wrote: Okay, so I did a matching uninstrument_attribute and pre_uninstrument_attribute, which look like really dumb names at this point. I propose the following name changes (in addition to the ones in my previous patch):

[sqlalchemy] Re: Python 2.6 hash behavior change

2008-03-05 Thread Michael Bayer
On Mar 5, 2008, at 3:35 AM, Denis S. Otkidach wrote: All hash table implementations (including one in Python) work the same way: first it looks up a list of key-value pairs by hash, and then iterate through the list to find a needed key by comparing it with = operator. Thus __eq__ method

[sqlalchemy] Re: Intersect of ORM queries

2008-03-05 Thread svilen
pardon my sql-ignorancy, but cant u express this in just one expression? it should be possible, it is a graph/set arithmetics after all... mmh, (could be very wrong!) something like - get all rows that has some b_id from the looked list - group(?) somehow by a_id, and then finger the a_id

[sqlalchemy] Re: Intersect of ORM queries

2008-03-05 Thread Michael Bayer
On Mar 5, 2008, at 10:50 AM, Eric Ongerth wrote: Anyway -- so what would really clean it all up would be: session.query(A).filter(A.bs.contains(list_of_bs_being_sought)).all(). THAT would do exactly what I'm trying to accomplish. But it would require contains() to accept a list and know

[sqlalchemy] InstrumentedList in SA 0.4.3

2008-03-05 Thread Acm
With SA version 0.3.11 I used to import InstrumentedList as follows: from sqlalchemy.orm.attributes import InstrumentedList Now I upgraded to SA 0.4.3 and cannot import InstrumentedList from the same file. I looked into the SQLAlchemy file attribute.py and noticed that this file uses the

[sqlalchemy] Re: Mapping and querying multiple levels of foreign key'd tables

2008-03-05 Thread Christoph Haas
Moin, Michael... thanks for your quick reply. On Wed, Mar 05, 2008 at 11:16:33AM -0500, Michael Bayer wrote: On Mar 5, 2008, at 4:14 AM, Christoph Haas wrote: Meanwhile I re-read http://www.sqlalchemy.org/docs/04/ormtutorial.html#datamapping_joins explaining that a relation path

[sqlalchemy] Re: Mapping and querying multiple levels of foreign key'd tables

2008-03-05 Thread Michael Bayer
On Mar 5, 2008, at 1:00 PM, Christoph Haas wrote: But now I'm curious. Why do I get the ArgumentError if I try .filter(Company==my_company) while .filter(Company.id==my_company.id) works? I was comparing ORM objects directly instead of fields/ properties of a mapped object.

[sqlalchemy] proposed FAQ entry

2008-03-05 Thread David Gardner
Ran into something this morning, fix and problem are simple. Q) How do I map a column that is a Python reserved word or already used by SA? A) table_a = Table ('tbl_a', metadata, autoload=True) mapper(AObj, table_a, properties={'type_col' : table_a.c.type, 'pass_col':table_a.c['pass']}) This

[sqlalchemy] Re: Intersect of ORM queries

2008-03-05 Thread Eric Ongerth
Cool. I wasn't sure if it was ready for filter(A.bs == list_of_bs). When I tried to do that before, I must have let some silly syntax error keep me from realizing that it was a workable construction. Thanks! On Mar 5, 8:20 am, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 5, 2008, at 10:50