Opened 16 years ago

Closed 12 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 anonymous, 16 years ago

milestone: post-1.0

comment:2 by (none), 15 years ago

milestone: post-1.0

Milestone post-1.0 deleted

comment:3 by Jacob, 15 years ago

Triage Stage: UnreviewedDesign decision needed

comment:4 by Luke Plant, 13 years ago

Severity: Normal
Type: New feature

comment:5 by Aymeric Augustin, 12 years ago

Easy pickings: unset
Resolution: wontfix
Status: newclosed
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.
Back to Top