On Monday, June 10, 2013 11:13:09 AM UTC-7, Michael Bayer wrote:
>
>
> [...]
>

> Using 0.8 you can pull the actual copied column "name" from the __table__:
>
> class SortedLookupTable(LookupTable):
>     __abstract__ = True
>
>     @declared_attr
>     def __mapper_args__(cls):
>         return {'order_by': [cls.__table__.c.name]}
>
> "cls.name" is the un-copied Column object still associated with the 
> LookupTable abstract class, ready for use on other mapped classes.    This 
> pattern is discussed in this section: 
> http://docs.sqlalchemy.org/en/rel_0_8/orm/extensions/declarative.html#resolving-column-conflicts.
>

I don't know why I didn't think to try that (one of my attempts did involve 
__table__, but not there).  That fixed it, thanks! 

I probably overlooked the "Resolving Column Conflicts" bit because I wasn't 
trying to redeclare a column at all originally, so didn't think it applied 
(plus I wasn't yet sure if @declared_attr worked on __mapper_args__ or not 
at that point)

>
> Also as far as the "order_by" mapper argument, there's no plans to remove 
> it, but it's a legacy argument that doesn't work well/at all with many 
> queries (such as queries against multiple entities, queries against 
> individual columns).
>
> It's handy in cases of lookup tables and other similar places -- but I 
have ran into cases where it breaks as well (unions, joins, etc.).  It 
would be handy if it could be quietly discarded in some places where it's 
presence causes things to break anyways, but if it's legacy I probably 
should try to phase out of using it and not expect any changes on that 
front.

-- Daniel
 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to