Let's say I have a model class Child, with an Integer column "birthOrder" 
and text column "birthSign", and a class Parent which has "children = 
relationship('Child', 
collection_class=attribute_mapped_collection('birthOrder'))".  This gives 
Parent a dictionary "children", keyed by the birth order.  I could do a 
Parent query with 
.join(Child).filter(Child.birthOrder==1).filter(Child.birthSign=="Virgo") 
 to find all the firstborn Virgos.

I'd like to dynamically build up a similar query, given the text 
"children[1].birthOrder" (plus knowledge that the operator and value were 
"==" and "Virgo").  I can split that string on "." to get "children[1]", 
and seeing the brackets I can assume the attribute_mapped_collection and 
split again to get "children" and the value "1",   Using inspect(), I can 
find out that "children" is a RelationshipProperty of the Child class, But 
how can I inspect to find out what column ("birthOrder") was passed in the 
attribute_mapped_collection?  The RelationshipProperty I get from inspect() 
has "collection_class", but this holds a lambda function.  Is knowledge 
that "birthOrder" was what was used lost inside that, or is there some 
other way I can find it?

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to