Ticket #68 (accepted enhancement)

Opened 5 years ago

Last modified 5 years ago

Implement filter on ManyToMany relationships

Reported by: ged Owned by: ged
Priority: normal Milestone: 0.8
Component: core Version: 0.6.1
Keywords: Cc:

Description

should simply add criteria to secondaryjoin

Change History

Changed 5 years ago by ged

  • status changed from new to accepted

Changed 5 years ago by ged

This is not as easy as I thought: you have to reuse the same table, and since a ManyToMany generated table (eg the one of the "unfiltered relationship") is not available at definition time, it fails...

class User(Entity):
    name = Field(String(50))
    addresses = ManyToMany('Address')
    boston_addresses = ManyToMany('Address', table=addresses.table,
                                  filter=lambda c: c.city == u'Boston')

Supporting a callable table argument might be a solution, though that'd be kinda ugly.

Changed 5 years ago by ged

  • milestone changed from 0.7 to 0.8
Note: See TracTickets for help on using tickets.