On Jan 25, 2009, at 8:41 PM, Brett wrote:

>
> The "Controlling Ordering" section of the docs mentions that using
> order_by on mappers is the standard way for setting a default ordering
> against a single mapped entity.  This seems like a good feature.  Is
> there another way?  Will this be deprecated in the future?

it wont be deprecated.

>
>
> What's also really weird is that if I put my __mapper_args__ at the
> beginning of the definition of Anything then I get the following
> errors for q1.union(q2),  query.union(q1, q2) and query.union_all(q1,
> q2):
>
>  File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.2-py2.5.egg/
> sqlalchemy/sql/visitors.py", line 247, in clone
>    cloned[element] = element._clone()
> AttributeError: 'str' object has no attribute '_clone'

its because youre using a string for the order by in the  
__mapper_args__.   use the Column object as the argument for order_by  
instead.

>
>
> If I put __mapper_args__ at the end it passes through.  Also if I use
> the original:
> u = union(q1.statement, q2.statement)
> print list(session.query(Anything).from_statement(u))

in this case, the Query receives your statement and doesn't try to  
change it.  in all other cases, the query selects "from" your  
statement and its the processing to generate that SQL which blows up  
on the string order_by as the mapper argument.



--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to