Opened 3 weeks ago

Last modified 11 days ago

#37175 assigned New feature

Add database backend methods to get hardcoded or nonexistent primary key values for tests — at Initial Version

Reported by: Tim Graham Owned by: Tim Graham
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Simon Charette Triage Stage: Accepted
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 (0)

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