[Django] #18088: Add a "supports_foreign_key" database feature to ease testing

14 views
Skip to first unread message

Django

unread,
Apr 8, 2012, 6:43:14 PM4/8/12
to django-...@googlegroups.com
#18088: Add a "supports_foreign_key" database feature to ease testing
--------------------------------------+--------------------
Reporter: akaariai | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
Currently our test coverage for checking that foreign keys are properly
enforced in the database are almost non-existent. One reason for this is
that it has not been easy to write tests, as some backends do not support
foreign keys and information of foreign key support has not been available
as !skipUnlessDBFeature target.

The attached patch adds a new database feature "supports_foreign_keys".
The patch also uses this feature in regressiontests/backends/tests.py. The
test results for backends tests are similar pre/post patch. MySQL + MyISAM
fails one test both pre/post patch, other backends work correctly.

This patch is needed for writing proper tests for #18081 for example.

--
Ticket URL: <https://code.djangoproject.com/ticket/18088>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 9, 2012, 5:18:18 AM4/9/12
to django-...@googlegroups.com
#18088: Add a "supports_foreign_key" database feature to ease testing
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.4
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

I wonder if we really need both can_introspect_foreign_keys and
supports_foreign_key... Could you investigate?

--
Ticket URL: <https://code.djangoproject.com/ticket/18088#comment:1>

Django

unread,
Apr 9, 2012, 6:26:56 AM4/9/12
to django-...@googlegroups.com
#18088: Add a "supports_foreign_key" database feature to ease testing
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.4
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by akaariai):

Surprisingly we can introspect foreign keys on SQLite, but they are not
enforced. Worth a comment though.

--
Ticket URL: <https://code.djangoproject.com/ticket/18088#comment:2>

Django

unread,
Apr 9, 2012, 7:10:41 PM4/9/12
to django-...@googlegroups.com
#18088: Add a "supports_foreign_key" database feature to ease testing
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.4
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by russellm):

@akaariai -- they're not enforced *currently*, but they could be. Foreign
key constraints were only added in SQLite 3.6.19 (see #14204); Django's
SQLite backend doesn't currently provide any way to exploit them.

--
Ticket URL: <https://code.djangoproject.com/ticket/18088#comment:3>

Django

unread,
Apr 9, 2012, 7:42:15 PM4/9/12
to django-...@googlegroups.com
#18088: Add a "supports_foreign_key" database feature to ease testing
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.4
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by akaariai):

* has_patch: 0 => 1


Comment:

Understood.

Main point is that supports_foreign_keys is not always the same as
can_introspect_foreign_keys. It would be actually possible to check if the
SQLite backend supports foreign keys in the _supports_foreign_keys() call
of SQLite. I am not going to piggy-back that change into this ticket. The
current changes are relatively simple, SQLite foreign key support is not.

--
Ticket URL: <https://code.djangoproject.com/ticket/18088#comment:4>

Django

unread,
Jun 16, 2012, 1:42:47 AM6/16/12
to django-...@googlegroups.com
#18088: Add a "supports_foreign_key" database feature to ease testing
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.4
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage:
Keywords: web design | Unreviewed
companies | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 1 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by jaffa):

* keywords: => web design companies
* needs_tests: 0 => 1


Comment:

The utilization of databases is now so widespread that virtually every
technology and product relies on databases and DBMSs for its development
and commercialization, or even may have such software embedded in it.
Also, organizations and companies, from small to large, depend heavily on
databases for their operations. Thanks.
Regards,
http://www.webdesigncompanies.com/

--
Ticket URL: <https://code.djangoproject.com/ticket/18088#comment:5>

Django

unread,
Jul 7, 2012, 8:26:34 AM7/7/12
to django-...@googlegroups.com
#18088: Add a "supports_foreign_key" database feature to ease testing
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.4
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage: Design
Keywords: | decision needed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* stage: Unreviewed => Design decision needed


Comment:

Sqlite 3.6.19 was released nearly three years ago. Debian stable ships
Sqlite 3.7.3.

Shouldn't we at some point:
- have a minimal version requirement for Sqlite,
- deprecate support for MySQL + MyISAM,
and support only "sane" databases -- that is, databases that enforce
foreign keys?

This is well beyond the scope of this ticket, but I'm not thrilled by the
idea of adding code to deal with broken databases. Make that a -0...

Django

unread,
Mar 23, 2013, 4:26:26 PM3/23/13
to django-...@googlegroups.com
#18088: Add a "supports_foreign_key" database feature to ease testing
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: 1.4
Component: Testing framework | Resolution:
Severity: Normal | Triage Stage: Design
Keywords: | decision needed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

Can we make a decision? Anssi, it's your call.

--
Ticket URL: <https://code.djangoproject.com/ticket/18088#comment:6>

Django

unread,
Mar 23, 2013, 6:50:54 PM3/23/13
to django-...@googlegroups.com
#18088: Add a "supports_foreign_key" database feature to ease testing
--------------------------------------+------------------------------------

Reporter: akaariai | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by akaariai):

* stage: Design decision needed => Accepted


Comment:

I think that as long as we have databases that do not support foreign keys
then supports_foreign_keys flag is needed. So, accepted. This could of
course be closed if somebody were to remove all databases without foreign
key support.

--
Ticket URL: <https://code.djangoproject.com/ticket/18088#comment:7>

Django

unread,
Jun 13, 2014, 2:13:50 PM6/13/14
to django-...@googlegroups.com
#18088: Add a "supports_foreign_key" database feature to ease testing
--------------------------------------+------------------------------------

Reporter: akaariai | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timo):

* needs_better_patch: 0 => 1


Comment:

Patch no longer applies cleanly.

--
Ticket URL: <https://code.djangoproject.com/ticket/18088#comment:8>

Django

unread,
Nov 4, 2014, 5:41:20 PM11/4/14
to django-...@googlegroups.com
#18088: Add a "supports_foreign_key" database feature to ease testing
--------------------------------------+------------------------------------

Reporter: akaariai | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Testing framework | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by timgraham):

The `supports_foreign_keys` flag was added in
d683263f97aedd67f17f4b78ac65d915f4e70d36, but there are still bits of the
proposed patch that could be applied.

--
Ticket URL: <https://code.djangoproject.com/ticket/18088#comment:9>

Reply all
Reply to author
Forward
0 new messages