Add support for "Conditional" references and reference sets
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Storm |
New
|
Undecided
|
Unassigned |
Bug Description
Yesterday vds asked me if Storm included a way to do "conditional references". This is a case where the foreign key relationship is one to many, but there is some flag for selecting a single item from that set (e.g. a boolean value, comparing a date field, etc). Often such a relationship would be accompanied by a database level conditional unique index.
I'd imagine that this feature could be useful for Launchpad too: an obvious example would be a person's preferred email address. The Person <-> EmailAddress relationship is one to many, but at most one of those address can be in the PREFERRED state. I'd imagine this case could look something like:
preferred_email = Reference(id, EmailAddress.
I realise that not all features of Reference() would make sense in t his case, but enough of them would to make it useful. Things that should work:
1. Reference.
2. caching of linked object: should work same as before: break relation if either object changes.
3. expression builder for "Reference == obj": Same as now, but have to make sure obj satisfies additional conditions. Checking with compile_
Things that don't have obvious answers:
1. Reference.
2. Unsetting reference: do you unset the foreign key, or do something to make the extra conditional expression fail?
See also bug 490280