Hello!
I have table wordforms and WordformMapping associated with it. Bi-
directional self-relation is expressed by using association table with
attributes named "infinitives" and "forms". I am using Elixir for
mapping definition so I cannot access association table with it's
columns explicitly.
I am trying to rewrite following query, which operates on table
columns directly (InfinitivesMapping is a present association table's
name):
query = transaction.query( database.WordFormsMapping )
query = query.filter( database.WordFormsMapping.wordform_id ==
database.InfinitivesMapping.wordform_id )
query =
query.filter( database.InfinitivesMapping.infinitive_id.in_( [ 
i.form.mapping.wordform_id
for i in form.infinitives ] ) )
results = query.all( )
In other words for a given WordformMapping I want to select all
WordformMappings associated with it through infinitives relation and
then select all WordformMappings associated with these infinitives
through forms relation.
I expressed it using python code and available relations:
reduce(lambda acc, cur : acc + cur.forms, form.mapping.infinitives,
[])
but generated SQL is far from optimal.
Is there a way to express it using relational operators combination to
reduce the ammount of SQL-queries?
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to