Opened 6 years ago

Closed 5 years ago

Last modified 9 months ago

#30397 closed New feature (fixed)

Allow app_label and class to be specified in the name argument for indexes and constraints.

Reported by: Mariusz Felisiak Owned by: Can Sarıgöl
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Allow %(app_label)s and %(class)s to be specified in name argument for BaseConstraint (CheckConstraint, UniqueConstraint) and Index:

  • %(class)s should be replaced by the lowercased name of the child class that the field is used in,
  • '%(app_label)s should be replaced by the lowercased name of the app the child class is contained within.

This should allow for specifying check constraints and partial indexes (which name's are mandatory) in abstract models.
Based on discussion in #30362.

Change History (13)

comment:1 by Can Sarıgöl, 6 years ago

Has patch: set
Owner: changed from nobody to Can Sarıgöl
Status: newassigned

comment:2 by Mariusz Felisiak, 5 years ago

Needs tests: set
Patch needs improvement: set

comment:3 by Can Sarıgöl, 5 years ago

Needs tests: unset
Patch needs improvement: unset

comment:4 by Mariusz Felisiak, 5 years ago

Needs tests: set
Patch needs improvement: set

comment:5 by Can Sarıgöl, 5 years ago

Patch needs improvement: unset

comment:6 by Can Sarıgöl, 5 years ago

Needs tests: unset

comment:7 by Mariusz Felisiak, 5 years ago

Patch needs improvement: set

comment:8 by Can Sarıgöl, 5 years ago

Patch needs improvement: unset

comment:9 by Carlton Gibson, 5 years ago

Patch needs improvement: set

OK, as per discussion on the PR, this is blocked pending a couple of refactorings. Mainly #30613. Let's review again after that.

comment:10 by Can Sarıgöl, 5 years ago

Patch needs improvement: unset

#30613 has been merged. I guess that this pr is available to review again.

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In febe136d:

Fixed #30397 -- Added app_label/class interpolation for names of indexes and constraints.

comment:12 by GitHub <noreply@…>, 9 months ago

In 9e35c8b:

Refs #30397 -- Optimized interpolation of index and constraint names a bit.

comment:13 by GitHub <noreply@…>, 9 months ago

In 1669e549:

Refs #30397 -- Optimized interpolation of index and constraint names a bit more.

Note: See TracTickets for help on using tickets.
Back to Top