I think you have to use the table.c collection for that. SQLA doesn't add any instrumentation to the composite class itself (i.e. which would make Vertex.start into something special). You can go through the effort to add descriptors to Vertex yourself, however and then you'd be able to use them in expressions.
On Jun 13, 2009, at 6:35 PM, Scott Torborg wrote: > > Sorry, for the stupid question, but I'm out of coffee. > > When using a composite column type, how can I use the individual > columns for filtering and ordering operations? > > Based off the example from the ORM docs: > http://gist.github.com/129457 > > What if I want to order by the x values of the composite column > 'start'? My instinct would be something like > > session.query(Vertex).order_by(Vertex.start.x) > > But Vertex.start.x doesn't exist. Is there a clean way to do this? > > One possible workaround is to just get the column object directly from > vertices.c., but that seems non-ideal, since you don't really know > what the underlying column name is going to be for each instance of a > composite column type. > > session.query(Vertex).order_by(vertices.c.x1) > > Thanks, > Scott > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
