Re: [sqlalchemy] Relationships using "max"

2014-02-03 Thread Michael Bayer
On Feb 3, 2014, at 11:00 AM, Josh Kuhn wrote: > Would I be correct in assuming this Version object won't be in the same > identity map as the other Version objects? no, the identity mapping is based on the class + primary key, so as long as the primary key consists of the same columns (i don’

Re: [sqlalchemy] Relationships using "max"

2014-02-03 Thread Josh Kuhn
Would I be correct in assuming this Version object won't be in the same identity map as the other Version objects? On Fri, Jan 31, 2014 at 9:45 PM, Michael Bayer wrote: > > On Jan 31, 2014, at 8:51 PM, Josh Kuhn wrote: > > This is pretty amazing. I get it to *almost* work. The issue seems to be

Re: [sqlalchemy] Relationships using "max"

2014-01-31 Thread Michael Bayer
On Jan 31, 2014, at 8:51 PM, Josh Kuhn wrote: > This is pretty amazing. I get it to *almost* work. The issue seems to be that > I don't use the database column names as my model attribute names. The db > column names are really obfuscated, so it's more like: > > class Version(Base): > id

Re: [sqlalchemy] Relationships using "max"

2014-01-31 Thread Josh Kuhn
This is pretty amazing. I get it to *almost* work. The issue seems to be that I don't use the database column names as my model attribute names. The db column names are really obfuscated, so it's more like: class Version(Base): id = Column('vrsn_nbr', Integer, primary_key=True) date = Colu

Re: [sqlalchemy] Relationships using "max"

2014-01-31 Thread Michael Bayer
well I can get it to work for lazy loading like this: expr = select([func.max(Version.id)]).\ where(Version.object_id == Object.id).\ correlate_except(Version).as_scalar() Object.current_version = relationship(Version, primaryjoin=and_(