Re: [sqlalchemy] with_polymorphic query and parent attribute filtering

2012-11-14 Thread tonthon
Le 14/11/2012 06:19, Michael Bayer a écrit : On Nov 13, 2012, at 3:34 AM, tonthon wrote: Hi, I'm using polymorphism for some of my models and I'm wondering how I should use the with_polymorphic query method. Consider the following: class A(Base): type_ = Column(Integer,

[sqlalchemy] with_polymorphic query and parent attribute filtering

2012-11-13 Thread tonthon
Hi, I'm using polymorphism for some of my models and I'm wondering how I should use the with_polymorphic query method. Consider the following: class A(Base): type_ = Column(Integer, nullable=False) arg = Column(String(20)) __mapper_args__ = {'polymorphic_on': type_,

Re: [sqlalchemy] with_polymorphic query and parent attribute filtering

2012-11-13 Thread Michael Bayer
On Nov 13, 2012, at 3:34 AM, tonthon wrote: Hi, I'm using polymorphism for some of my models and I'm wondering how I should use the with_polymorphic query method. Consider the following: class A(Base): type_ = Column(Integer, nullable=False) arg = Column(String(20))

[sqlalchemy] with_polymorphic mapper option for future classes

2011-07-20 Thread Torsten Landschoff
Hi *, is there a way to use the with_polymorphic mapper option for classes yet to be defined? My problem is that I have a base class for a number of different database objects. There are few specific leafs classes of which many instances are loaded at once. Currently, I pass

Re: [sqlalchemy] with_polymorphic mapper option for future classes

2011-07-20 Thread Michael Bayer
perhaps we'd want to establish mapper.with_polymorphic as a setter that will perform the requisite validations on it whenever it is set.I think you can set it right now on the mapper at any point, it doesn't seem to be consulted in any configurational way. The only validations that occur

[sqlalchemy] with_polymorphic() and merging two subclassed Query ?

2010-09-02 Thread Julien Cigar
Hello, Another quick question on .with_polymorhpic() .. :) When I use inheritance I always subclass a Query object per mapped (child) class, for example : class QueryRoot(orm.Query): def available_to_all_children(self): return self.filter(...) class RootModel(object): query =

Re: [sqlalchemy] with_polymorphic() and merging two subclassed Query ?

2010-09-02 Thread Michael Bayer
On Sep 2, 2010, at 8:59 AM, Julien Cigar wrote: Hello, Another quick question on .with_polymorhpic() .. :) When I use inheritance I always subclass a Query object per mapped (child) class, for example : class QueryRoot(orm.Query): def available_to_all_children(self): return

Re: [sqlalchemy] with_polymorphic() and merging two subclassed Query ?

2010-09-02 Thread Julien Cigar
On 09/02/2010 17:55, Michael Bayer wrote: On Sep 2, 2010, at 8:59 AM, Julien Cigar wrote: Hello, Another quick question on .with_polymorhpic() .. :) When I use inheritance I always subclass a Query object per mapped (child) class, for example : class QueryRoot(orm.Query): def

[sqlalchemy] with_polymorphic()

2010-08-30 Thread Julien Cigar
Hello, Quick question, is there a way to use .with_polymorphic() on a Query with existing criterion ? I have the case where I have 2 queries with the same criteria where one of those queries is a count(*). I would like to avoid multiple LEFT JOIN because criteria in the count(*) query

Re: [sqlalchemy] with_polymorphic()

2010-08-30 Thread Michael Bayer
On Aug 30, 2010, at 5:59 AM, Julien Cigar wrote: Hello, Quick question, is there a way to use .with_polymorphic() on a Query with existing criterion ? I have the case where I have 2 queries with the same criteria where one of those queries is a count(*). I would like to avoid multiple

Re: [sqlalchemy] with_polymorphic()

2010-08-30 Thread Julien Cigar
On 08/30/2010 16:06, Michael Bayer wrote: On Aug 30, 2010, at 5:59 AM, Julien Cigar wrote: Hello, Quick question, is there a way to use .with_polymorphic() on a Query with existing criterion ? I have the case where I have 2 queries with the same criteria where one of those queries is a

[sqlalchemy] with_polymorphic() and more than one level of inheritance

2010-07-16 Thread Julien Cigar
Hello, I have the following mappers: orm.mapper(Content, table.content, polymorphic_on = table.content.c.content_type_id, ...) orm.mapper(News, table.news, inherits = Content, polymorphic_on = table.content.c.content_type_id) orm.mapper(PlatformNews, table.platform_news,

Re: [sqlalchemy] with_polymorphic() and more than one level of inheritance

2010-07-16 Thread Michael Bayer
On Jul 16, 2010, at 7:34 AM, Julien Cigar wrote: Hello, I have the following mappers: orm.mapper(Content, table.content, polymorphic_on = table.content.c.content_type_id, ...) orm.mapper(News, table.news, inherits = Content, polymorphic_on = table.content.c.content_type_id)

[sqlalchemy] with_polymorphic

2010-04-01 Thread Kent
What is the difference between: session.query(Employee).join([Engineer, Manager]).\ filter(or_(Engineer.engineer_info=='w', Manager.manager_data=='q')) and session.query(Employee).with_polymorphic([Engineer, Manager]).\ filter(or_(Engineer.engineer_info=='w', Manager.manager_data=='q'))

Re: [sqlalchemy] with_polymorphic

2010-04-01 Thread Michael Bayer
On Apr 1, 2010, at 8:22 PM, Kent wrote: What is the difference between: session.query(Employee).join([Engineer, Manager]).\ filter(or_(Engineer.engineer_info=='w', Manager.manager_data=='q')) and session.query(Employee).with_polymorphic([Engineer, Manager]).\