1. Michael Bayer
  2. sqlalchemy
  3. Issues


Issue #2846 new

many-to-one relationship interpretation by query

Michael Bayer
repo owner created an issue

consolidating #1328, #2797, #2845 as these are all dealing with the same thing from different angles.

SomeClass.some_m2o, which refers to OtherEntity as a many-to-one, would be interpreted:

  1. for sess.query(SomeClass.some_m2o) as sess.query(OtherEntity)

  2. for sess.query(SomeClass).filter(SomeClass.some_m2o == OtherEntity) as filter(SomeClass.other_entity_id == OtherEntity.id)

  3. for sess.query(SomeClass).order_by(SomeClass.some_m2o), group_by(SomeClass.some_m2o), as order_by/group_by SomeClass.other_entity_id

  4. as is currently the case, sess.query(SomeClass).filter(SomeClass.some_m2o == other_entity) compares to other_entity.id

any other query.something(SomeClass.m2o..something) type requests should get put here.

Comments (4)

  1. Log in to comment