Opened 58 minutes ago

Last modified 41 minutes ago

#37175 assigned New feature

Add database backend methods to get hardcoded or nonexistent primary key values for tests

Reported by: Tim Graham Owned by: Tim Graham
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

While hardcoding primary key values in the Django test suite is avoided as much as possible, sometimes there are legitimate uses. The existing hardcoded integer values, however, don't work on databases that don't use integer primary key values. For example, MongoDB uses DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField".

I propose adding new methods DatabaseOperations.get_hardcoded_pk() and get_nonexistentd_pk() to allow a database backend to provide suitable values, minimizing the size of the Django fork needed for running the test suite on such databases.

Change History (1)

comment:1 by Tim Graham, 41 minutes ago

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