On Jun 1, 2007, at 3:04 PM, Eric Ongerth wrote:

>
> The right usage of append_whereclause() seems to be:
>
> s = sometable.select()
> s.append_whereclause(col==val)
> etc.
>
>
> I just had a kind of tough time recently when I actually assigned the
> result instead:
>
> s = sometable.select()
> s = s.append_whereclause(col==val)
>
>
> Granted, this was a mistake I should not have made, and I'm
> responsible for it.  But the resulting behavior was unexpected: s goes
> to None because append_whereclause() returns None.
>
> What I'd rather see is either an error warning not to assign the
> result to anything, or to just have foo.append_whereclause() return
> the resulting foo.  Is that a reasonable request, or are there reasons
> it shouldn't be done?  Unnecessary, perhaps?
>
> Before answering, consider why I feel I made the mistake in the first
> place.  When working with a class instead of a table, the similar
> process goes thus:
>
> q = someclass.query()
> q = q.filter(col==val)
>
> -- so it would be natural/smooth to guess that when I switch a part of
> my code from dealing with classes to dealing with their mapped tables,
> I could use similar semantics rather than switching from assignment/
> function-evaluation to imperative.  No?

making select() 'generative' has been under discussion.  questions  
include whether to copy the select each time before returning it as  
well as what the methods should be called, i.e. maybe "where()"  
instead of "append_whereclause()".



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to