[sqlalchemy] Re: assign_mapper query methods

2007-06-01 Thread Mike Orr
I guess it depends how you look at it. To me assign_mapper adds some Query methods and not others; e.g., .select and .count but not .filter . I assume that's because .filter is so new. But in the manual under Generative Query Methods it implies that .select and .filter are parallel; i.e., you

[sqlalchemy] Re: assign_mapper query methods

2007-06-01 Thread Michael Bayer
as it turns out, assign_mapper's monkeypatched methods (and they are all monkeypatched, not sure why you singled out query()) dont conflict with mapped properties since those properties get set up subsequent to the assign_mapper call and replace them. however adding new methods to assign_mapper

[sqlalchemy] Re: assign_mapper query methods

2007-06-01 Thread Christoph Haas
On Fri, Jun 01, 2007 at 07:17:19AM -0700, Michael Bayer wrote: so i didnt add filter() because i didnt feel like getting all the bug reports from people who have instance variables called filter, and also because my plan was to do away with *all* the select/filter/etc methods and have

[sqlalchemy] Re: assign_mapper query methods

2007-06-01 Thread Gaetan de Menten
For what it's worth I personally vote to get rid of all those query methods (except query() itself, of course). On 6/1/07, Michael Bayer [EMAIL PROTECTED] wrote: as it turns out, assign_mapper's monkeypatched methods (and they are all monkeypatched, not sure why you singled out query()) dont

[sqlalchemy] Re: assign_mapper query methods

2007-06-01 Thread Michael Bayer
On Jun 1, 11:37 am, Christoph Haas [EMAIL PROTECTED] wrote: sooner or later. Am I right that we are just talking of john = session.query(User).get_by(name=john) versus john = User.get_by(name=john) well assign_mapper gives you the *huge* advantage that you can forget about the

[sqlalchemy] Re: assign_mapper query methods

2007-06-01 Thread Gaetan de Menten
On 6/1/07, Michael Bayer [EMAIL PROTECTED] wrote: On Jun 1, 11:37 am, Christoph Haas [EMAIL PROTECTED] wrote: sooner or later. Am I right that we are just talking of john = session.query(User).get_by(name=john) versus john = User.get_by(name=john) well assign_mapper

[sqlalchemy] Re: assign_mapper query methods

2007-06-01 Thread Michael Bayer
On Jun 1, 2007, at 12:46 PM, Gaetan de Menten wrote: To get this straight, this was my personal opinion, not the one from the whole elixir crew. The other option which was discussed was to get rid of assignmapper altogether (in favor of defining the methods on our base class so that people

[sqlalchemy] Re: assign_mapper query methods

2007-06-01 Thread David Shoemaker
Both session.query(User).select() and User.query().select() seem more verbose than they need to be for my taste. However, I think most people (myself included) define a base class for all their mapped classes. I've always used this base class to provide the interface I want, no matter what

[sqlalchemy] Re: assign_mapper query methods

2007-06-01 Thread Christoph Haas
On Fri, Jun 01, 2007 at 10:50:33AM -0700, David Shoemaker wrote: Both session.query(User).select() and User.query().select() seem more verbose than they need to be for my taste. However, I think most people (myself included) define a base class for all their mapped classes. Uhm,

[sqlalchemy] Re: assign_mapper query methods

2007-06-01 Thread David Shoemaker
I used to have: .set(**kw) .update(whereclause, **kw) # this does table.update().execute() .count(whereclause) # table.count(whereclause).scalar() .delete_one(id) .load(*args) # returns a mapper with a bunch of eager loads .add_properties(dict) Luckily, great minds think alike and I was able to

[sqlalchemy] Re: assign_mapper query methods

2007-06-01 Thread Mike Orr
assign_mapper is doing five different things: 1 Hide the session context and session 2 .query() 3 shadowed query methods (get*/select*/count/join*/etc) 4 shadowed session methods (flush/delete/save/etc) 5 connecting a DynamicMetaData whenever it needs to (1) we all

[sqlalchemy] Re: assign_mapper query methods

2007-06-01 Thread Michael Bayer
On Jun 1, 2007, at 6:47 PM, Mike Orr wrote: (4) I haven't used so I'm not sure if it's better or worse than session.* . But grafting fewer rather than more methods onto the mapped class makes sense. instance.flush() is often misused, since flush() with just one instance wont always flush

[sqlalchemy] Re: assign_mapper query methods

2007-05-31 Thread Michael Bayer
heres the question. Query gets 10 new methods one day. do we then add 10 methods to assign_mapper() ? must the user class be a total clone of Query ? assign_mapper just bugs me for this reason. hence i like entity.query() better. im not sure which one youre saying you prefer ? On May 31,

[sqlalchemy] Re: assign_mapper query methods

2007-05-31 Thread Christoph Haas
TOFU day? Okay, me too. ;) If I may cast a vote: yes, please add these 10 methods (if they are remotely connected to selecting or changing rows) and start with .filter(). I'm working with assign_mapped objects most the time and just have to use a completely different (Query) syntax if I want to

[sqlalchemy] Re: assign_mapper query methods

2007-05-31 Thread sdobrev
maybe keep only _one_ method which gives a fullblown Query() object, which then can be used as one wish? On Friday 01 June 2007 06:47:01 Michael Bayer wrote: heres the question. Query gets 10 new methods one day. do we then add 10 methods to assign_mapper() ? must the user class be a total