Michael Bayer ha scritto: > On Apr 3, 2007, at 11:26 AM, Glauco wrote: > > >> Yes, but i lost generative methods filter_by >> >> > > First of all, filter_by() has no interaction with instances(). with > instances(), no SQL is constructed by the Query object - it takes the > result set of whatever exact select() statement youve constructed and > thats it. its roughly equivalent functionality to hibernate's > session.createSQLQuery(). its used when you know the exact SQL you > want to issue and youd rather not have Query build the SQL for you. > > so as far as getting columns in conjunction with filter_by(), we are > only talking about add_column() and add_entity(). > > so basically youre saying that this: > > session.query(MyClass).filter_by(foo='bar').list() > > will return instances of MyClass, while this: > > session.query(MyClass).filter_by(foo='bar').add_column > ('somecolumn').list() > > will return a result set of "somecolumn". but *not* MyClass. thats > probably not what people expect. > > the only way I can see this happening would be some new method: > > session.query(MyClass).filter_by(foo='bar').remove_entity > (MyClass).add_column('somecolumn').list() > > or perhaps: > > session.query(MyClass).filter_by(foo='bar').set_column > ('somecolumn').list() > > > i think set_column is a good choice, because in big mapper ( or big select over a lot of tables ) the sa and DB must manipulate a lot of unused fields.
another example is a mapper i've done overa a join (i call it a mapper ove a view) in this case i must do it for retrieve the cartesian product of the 3 tables, but all time the result object is bigger than what i'm searching for. For this reason i want to optimize memory occupation of result object. Thank you Glauco -- +------------------------------------------------------------+ Glauco Uri - Programmatore glauco(at)allevatori.com Sfera Carta Software® [EMAIL PROTECTED] Via Bazzanese,69 Casalecchio di Reno(BO) - Tel. 051591054 +------------------------------------------------------------+ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---