Opened 7 years ago

Closed 4 years ago

#8437 closed New feature (wontfix)

Feature Request: distinct_between('team_home', 'team_away') similar to unique_together

Reported by: ritlim 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 7 years ago by anonymous

  • milestone set to post-1.0
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:3 Changed 7 years ago by jacob

  • Triage Stage changed from Unreviewed to Design decision needed

comment:4 Changed 4 years ago by lukeplant

  • Severity set to Normal
  • Type set to New feature

comment:5 Changed 4 years ago by aaugustin

  • Easy pickings unset
  • Resolution set to wontfix
  • Status changed from new to 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.
Back to Top