[sqlalchemy] Double many-to-many relation filter headache

2012-09-28 Thread Vlad K.
Hello list, I don't think my brain is currently capable of figuring out the SQL itself, let alone how to do it with SQLA. I've got the following models: City Location Item Category Location belongs to one of many Cities via simple Location.city_id foreign key Location belongs to one or

Re: [sqlalchemy] [Q] Why the following emits SQL for slot access?

2012-09-28 Thread lenartlad
Hello. Thank you for the tips. I stick to my simple approach for the time being: _rows = q.all() rows = unwrap(_rows) I need the cache within the context of one method only. Ladislav Lenart Od: Michael Bayer mike...@zzzcomputing.com On Sep 27, 2012, at 4:37 PM, Ladislav Lenart

Re: [sqlalchemy] query joining and filtering with table inheritance

2012-09-28 Thread lenartlad
Hello. I am not at my development environment now so I cannot test it, but I think you want this: http://docs.sqlalchemy.org/en/rel_0_7/orm/inheritance.html?highlight=of_type#basic-control-of-which-tables-are-queried Ladislav Lenart PS: I'm by no means a DB or SQLA expert too :-) Od: Iain

Re: [sqlalchemy] query joining and filtering with table inheritance

2012-09-28 Thread Michael Bayer
This is the right answer. if you query(Contact).with_polymorphic([Person, Organization]), you can refer to Person.attribute and Organization.attribute in your query. It will produce a LEFT OUTER JOIN from contact to each of the related tables. On Sep 28, 2012, at 7:05 AM,

[sqlalchemy] Automatically Adding Casting to 'CASE' Expressions in Dialects

2012-09-28 Thread Alex D.
Is there a good way to have a dialect automatically add casting to 'THEN' expressions in 'CASE' statements? I'm working on a dialect for the H2 database, via Jython. H2 requires values in a 'THEN' expression to have explicit casts (see: Unknown data type thrown with a case statement where all

Re: [sqlalchemy] Automatically Adding Casting to 'CASE' Expressions in Dialects

2012-09-28 Thread Michael Bayer
On Sep 28, 2012, at 11:15 AM, Alex D. wrote: Is there a good way to have a dialect automatically add casting to 'THEN' expressions in 'CASE' statements? I'm working on a dialect for the H2 database, via Jython. H2 requires values in a 'THEN' expression to have explicit casts (see:

Re: [sqlalchemy] Automatically Adding Casting to 'CASE' Expressions in Dialects

2012-09-28 Thread Alex D.
Roger that, thanks for the prompt response. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/XU4Zfrz8KJQJ. To post to this group, send email to

Re: [sqlalchemy] query joining and filtering with table inheritance

2012-09-28 Thread Iain Duncan
On Fri, Sep 28, 2012 at 7:06 AM, Michael Bayer mike...@zzzcomputing.comwrote: This is the right answer. if you query(Contact).with_polymorphic([Person, Organization]), you can refer to Person.attribute and Organization.attribute in your query. It will produce a LEFT OUTER JOIN from

[sqlalchemy] Feature request - sqlalchemy.sql.operators.ColumnOperators.not_in_

2012-09-28 Thread Jonathan Vanasco
I would really like to make a feature request for a `not_in_` operator for sqlalchemy.sql.operators.ColumnOperators there are at least 2 ways to make a valid query right now : filter( ~ table.column.in_( (1,2,) ) ) filter( sqlalchemy.not( table.column.in_( (1,2,) ) ) so there isn't any

Re: [sqlalchemy] Feature request - sqlalchemy.sql.operators.ColumnOperators.not_in_

2012-09-28 Thread Michael Bayer
On Sep 28, 2012, at 1:54 PM, Jonathan Vanasco wrote: I would really like to make a feature request for a `not_in_` operator for sqlalchemy.sql.operators.ColumnOperators there are at least 2 ways to make a valid query right now : filter( ~ table.column.in_( (1,2,) ) ) filter(

Re: [sqlalchemy] SQLAlchemy ORM Object caching with relationships and invalidation

2012-09-28 Thread Michael Bayer
On Sep 27, 2012, at 1:28 AM, Michael Kowalchik wrote: Lets say I have object A that's in the cache and it has a relationship, A.B that was stored along with it in the cache. If I retrieve A from the cache I can get A.B and I get the cached copy of B. If B is modified, however, then my