On Jul 1, 2011, at 4:56 PM, Arturo Sevilla wrote:

> My only doubt now is whether you can query over the fields of the composite 
> attribute. In the documentation an example is made of a query with a 
> comparison of the whole data structure:
> 
> session.query(Vertex).filter(Vertex.start == Point(3, 4))
> 
> But it also says: "As of SQLAlchemy 0.7, composites have been simplified such 
> that they no longer “conceal” the underlying column based attributes"
> 
> Does this mean that you can do a query like this:
> 
> session.query(Vertex).filter(Vertex.start.x == 3)
> 
> Does this work or is there a way to do this or do I have to query using the 
> corresponding column definitions of the table object?

Well, there is a way to do that which is to create descriptors on Vertex for 
each of "start", "end", there is no instrumentation for these right now and an 
instance of Vertex stores "start" and "end" using Python's default attribute 
mechanisms.   The descriptors would then link up to the columns back on the 
parent at the class  level to produce SQL expression behavior.    It's 
definitely doable and could be a behavior built into SQLA. 

The change in 0.7 refers to the corresponding "start" and "end" columns of the 
parent table.   So in your example you can query with User.HomePage and 
User.Telephone directly.     


> 
> Thanks
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/sqlalchemy/-/TUTlybahglQJ.
> 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.

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