I couldn't create a simple test case, but I have analyzed the cause of
the problem.

The order_by() method is sent a list as an argument, but the argument
'criterion' becomes a tuple
because of the "def order_by(self, *criterion)" syntax.

in the case of "if self._aliases_tail:" , 'criterion' becomes a list
again, but if _aliases_tail is None it remains a tuple.

Now the cause of the problem is that on the first call to order_by(),
self._aliases_tail exists, and on the 2nd call, following the
reset_joinpoint() call, it is None. Therefore the '_order_by member'
is initialized as a list, and later a tuple is attempted to be
concatenated and hence the failure.

The calling code from my source looks like this:

myquery = Node.query()
myquery = myquery.join('parent', aliased=True)

myquery = myquery.order_by(Node.c.name)                          #
_aliases_tail exists for this call
myquery = myquery.reset_joinpoint().order_by(Node.c.popularity)  #
_aliases_tail is None for this call




On May 6, 10:25 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On May 6, 2008, at 3:08 PM, Moshe C. wrote:
>
>
>
>
>
> > Both methods cause a crash (yes, on 0.4.5) .
>
> > converting a tuple to a list in sqlalchemy/orm/query.py fixes it for
> > one of the methods, for the other you need to do the opposite, convert
> > a list to a tuple.
>
> > File '/home/moshe/top/webapp/rma/rma/controllers/list.py', line 215 in
> > list_sources
> >  myquery =
> > myquery.reset_joinpoint().order_by(model.Source.c.popularity)
> > File '/home/moshe/top/webapp/rma/sqlalchemy/util.py', line 198 in
> > starargs_as_list
> >  return func(self, *to_list(args[0], []), **kwargs)
> > File '/home/moshe/top/webapp/rma/sqlalchemy/orm/query.py', line 571 in
> > order_by
> >  q._order_by = q._order_by + criterion
> > TypeError: can only concatenate list (not "tuple") to list
>
> I cant reproduce that at all, even sending purposely wacky arguments
> to the previous order_by().    can you please provide a test case ?
--~--~---------~--~----~------------~-------~--~----~
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