Opened 8 years ago

Closed 5 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: master
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 Changed 8 years ago by anonymous

milestone: post-1.0
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 8 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

comment:3 Changed 8 years ago by Jacob

Triage Stage: UnreviewedDesign decision needed

comment:4 Changed 5 years ago by Luke Plant

Severity: Normal
Type: New feature

comment:5 Changed 5 years ago by Aymeric Augustin

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