Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#21099 closed Bug (fixed)

DistinctOnTests.setUp() breaks when DatabaseFeature.ignores_nulls_in_unique_constraints = True

Reported by: manfre Owned by: nobody
Component: Testing framework Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


Django-mssql doesn't implement can_distinct_on_fields, but the DistinctOnTests fail because the test setUp creates Celebrity records without specifying a value for a nullable field that has a unique constraint. Any database backend with ignores_nulls_in_unique_constraints = False will error on this setup, even if they would skip the tests.

I'm not in a position to run these tests to determine if the greatest_fan value can be set to something other than NULL.

Change History (6)

comment:1 Changed 3 years ago by manfre

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

It might be worth wrapping setUp(), or the entire class with a can_distinct_on_fields check to avoid doing the test prep work for every backend other than postgresql_psycopg2.

comment:2 Changed 3 years ago by akaariai

  • Triage Stage changed from Unreviewed to Accepted

Wrapping the whole class seems like the correct solution to me.

comment:4 Changed 3 years ago by akaariai

  • Triage Stage changed from Accepted to Ready for checkin

comment:5 Changed 3 years ago by Michael Manfre <mmanfre@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 018037736fe575307f5331ebb4b126a0c886ecef:

Fixed #21099 - Skip DistinctOnTests unless backend can_distinct_on_fields

comment:6 Changed 3 years ago by Claude Paroz <claude@…>

In e4c6fca6d21f6a6d16bd69d86928270b4d2d38fb:

Merge pull request #1622 from manfre/ticket-21099

Fixed #21099 - Skip DistinctOnTests unless backend can_distinct_on_field...

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