given the structure below (pasted from SA 0.5 docs of association object):

left_table = Table('left', metadata,
    Column('id', Integer, primary_key=True),
    Column('l_data', String(50))

right_table = Table('right', metadata,
    Column('id', Integer, primary_key=True),
    Column('r_data', String(50))

association_table = Table('association', metadata,
    Column('left_id', Integer, ForeignKey('left.id'), primary_key=True),
    Column('right_id', Integer, ForeignKey('right.id'), primary_key=True),
    Column('a_data', String(50))
    )

mapper(Parent, left_table, properties={
    'children':relation(Association, backref="parent")
})

mapper(Association, association_table, properties={
    'child':relation(Child, backref="parent_assocs")
})

mapper(Child, right_table)


what I would like to do is query the Association object while filtering
on parent_data and child_data and ordering the union, see below for a
pure sql version, but how in orm (if possible)?

  select id as id, l_data as data_ass, a_data as data
  from association left outer join left
  where l_data = 'filtervalue'
UNION
  select id as id, r_data as data_ass, a_data as data
  from association left outer join right
  where r_data = 'filtervalue'
order by data








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