[sqlalchemy] Re: inheritance and column_property() - subqueries are being limited

2010-08-05 Thread SQLAlchemy User
to it. As before, the generated sql is appending WHERE 'devtype' in 'Switch' to the end of the switch = Session.query(Switch)... statement, which I think is throwing off the subquery results (but I could be completely wrong). Thanks, S. On Aug 4, 5:11 pm, SQLAlchemy User sqlalchemyu...@gmail.com

[sqlalchemy] Re: now with code goodness: problems with single-table inheritance and column_properties?

2010-08-05 Thread SQLAlchemy User
Trying again without tab indents. Hopefully the formatting works this time. from objects import * class Device(Base): __tablename__=testdev devtype = Column(Unicode(20), primary_key = True) __mapper_args__ = {'polymorphic_on': devtype} mac = Column(Unicode(128), primary_key =

[sqlalchemy] Re: now with code goodness: problems with single-table inheritance and column_properties?

2010-08-05 Thread SQLAlchemy User
On Aug 5, 3:11 pm, Michael Bayer mike...@zzzcomputing.com wrote: Ultimately you're looking for a self-referential correlation here.   In SQL, that always implies using aliases.   Your column_property needs to be against aliased(PC) and not PC itself.     Thanks - that did the trick. I

[sqlalchemy] Re: inheritance and column_property() - subqueries are being limited

2010-08-04 Thread SQLAlchemy User
...and I've figured out a workaround: in Switch(Device): pcs = relationship('PC', primaryjoin = 'Switch.mac == PC.switch_mac', lazy='dynamic') Now, switch.pcs.count() works :) S. On Aug 4, 5:00 pm, Zippy P sqlalchemyu...@gmail.com wrote: I have a single-table inheritance setup: class

[sqlalchemy] Re: Returning an attribute from an object when using query_property()?

2010-08-02 Thread SQLAlchemy User
I have the following code: class EventQuery(Query):   def histogram(self):     ''' return a histogram of source / count(source) given an eventquery''     ... ... class Event(Base):   __tablename__ = 'events'   query = Session.query_property(query_cls = EventQuery)   name =

[sqlalchemy] Re: Returning an attribute from an object when using query_property()?

2010-08-02 Thread SQLAlchemy User
On Aug 2, 11:34 am, Michael Bayer mike...@zzzcomputing.com wrote: values() should be using the least amount of memory of any approach - it only buffers 10 rows in memory at a time, and doesn't deal with session or object accounting at all so is also much more performant than all().  I dont

[sqlalchemy] Re: multi-table comparators / properties - how?

2010-06-02 Thread SQLAlchemy User
On Jun 2, 6:43 am, Michael Bayer mike...@zzzcomputing.com wrote: On Jun 2, 2010, at 12:48 AM, SQLAlchemy User wrote: OK, I get the need for column_property, but the select is fairly complex and involves unions of the containing class (and it hasn't been defined yet). How do I get around

[sqlalchemy] multi-table comparators / properties - how?

2010-06-01 Thread SQLAlchemy User
Hi all: Hoping some kind soul on the list will be able to advise on this use/ implementation problem I'm having: I have two tables (both declarative representations): the first, Device, describes devices (device ID, import time, other details), and the second, DeviceState, lists state changes

[sqlalchemy] Re: multi-table comparators / properties - how?

2010-06-01 Thread SQLAlchemy User
On Jun 1, 3:31 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jun 1, 2010, at 1:06 PM, SQLAlchemy User wrote: I have two tables (both declarative representations): the first, Device, describes devices (device ID, import time, other details), and the second, DeviceState, lists state