Opened 16 years ago
Closed 13 years ago
#8437 closed New feature (wontfix)
Feature Request: distinct_between('team_home', 'team_away') similar to unique_together
Reported by: | Rit Lim | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
class Game(models.Model): team_home = models.ForeignKey(Team, related_name="games_home") team_away = models.ForeignKey(Team, related_name="games_away") class Meta: distinct_between = ('team_home', 'team_away')
"distinct_between" should add this constraint to the database:
CHECK(team_home IS DISTINCT FROM team_away)
Change History (5)
comment:1 by , 16 years ago
milestone: | → post-1.0 |
---|
comment:2 by , 16 years ago
milestone: | post-1.0 |
---|
comment:3 by , 16 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:5 by , 13 years ago
Easy pickings: | unset |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
UI/UX: | unset |
I'm going to reject this idea for the following reasons:
- I sounds a bit too specialized — a unique index is a generic concept in databases; a check for two fields being different is business logic;
- Not all database backends support this syntax — or at least, I haven't seen a patch proving the contrary;
- It's easily implemented in a custom
save()
method.
Note:
See TracTickets
for help on using tickets.
Milestone post-1.0 deleted