Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#22653 closed Uncategorized (fixed)

Need to add database features flag in some of the test cases

Reported by: rahul.priyadarshi@… Owned by: nobody
Component: Testing framework Version: 1.7-beta-2
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

Some of the Database backend doesn't allow to defer constraints check like DB2 which doesn't allow to defer constraint check within a transaction also

Following test cases requires to check can_defer_constraint_checks
i) test cases under admin_views.tests.AdminViewDeletedObjectsTest test class
ii) test cases under serializers_regress.tests.SerializerTests test class

Following test cases requires supports_forward_references flag check
i) serializers.SerializersTransactionTestBase.test_forward_refs
ii) fixtures_regress.TestFixtures.test_loaddata_works_when_fixture_has_forward_refs
iii) fixtures_regress.TestFixtures.test_loaddata_forward_refs_split_fixtures

Attachments (2)

patch.diff (3.1 KB) - added by rahul.priyadarshi@… 3 years ago.
patch2.diff (3.3 KB) - added by anonymous 3 years ago.

Download all attachments as: .zip

Change History (9)

Changed 3 years ago by rahul.priyadarshi@…

Attachment: patch.diff added

comment:1 Changed 3 years ago by Aymeric Augustin

Triage Stage: UnreviewedAccepted

comment:2 Changed 3 years ago by Michael Manfre

Why does the patch use skipUnlessDBFeature in some places and skipUnless in others? Why not always use skipUnlessDBFeature?

Changed 3 years ago by anonymous

Attachment: patch2.diff added

comment:3 Changed 3 years ago by rahul.priyadarshi@…

Yes, It would be good if always use skipUnlessDBFeature. In new attached patch(patch2.diff) I have made this modification.

comment:4 Changed 3 years ago by Tim Graham

Couple of things I noticed:

  • The MySQL backend has supports_forward_references=False (blamed to 121d2e36), but after removing that (which changes it to True) the tests still pass (i.e. the existing test that has @skipUnlessDBFeature('supports_forward_references') is currently skipped on MySQL, but works fine). This issue is not necessarily related to this patch, except that additional tests that current pass on MySQL will be skipped. I'm not sure if supports_forward_references=False can be removed or if maybe it is only relevant for particular versions and/or storage engines in MySQL.
  • MySQL + SQLite have can_defer_constraint_checks=False but admin_views.tests.AdminViewDeletedObjectsTest and serializers_regress.tests.SerializerTests current pass (the patch would cause them to be skipped).

comment:5 Changed 3 years ago by rahul.priyadarshi@…

MySQL + SQLite can defer the constraint checking and can support forward reference until the end of the transaction. These test cases doing all the operation within a transaction only that's why these test case passes with MySQL+SQLite.

But it is not in case of dtatabse like DB2, which strictly follow constraint checking and can't defer it within a transaction also.

comment:6 Changed 2 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 99f5ea9cc8f41724e07b88c6142d0092961ce5e0:

Fixed #22653 -- Added some database feature flags to tests.

Thanks Rahul Priyadarshi.

comment:7 Changed 2 years ago by Tim Graham <timograham@…>

In 45e47f7b95aad98d91bb40e19dda14ae120980a4:

[1.7.x] Fixed #22653 -- Added some database feature flags to tests.

Thanks Rahul Priyadarshi.

Backport of 99f5ea9cc8 from master

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