[Django] #35156: Update Doc comment about SQLite foreign keys

11 views
Skip to first unread message

Django

unread,
Jan 30, 2024, 2:24:48 PM1/30/24
to django-...@googlegroups.com
#35156: Update Doc comment about SQLite foreign keys
-----------------------------------------+------------------------
Reporter: bcail | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: dev
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
[https://docs.djangoproject.com/en/5.0/topics/db/multi-db/#cross-database-
relations Multi-database docs] say the following:
{{{
However, if you’re using SQLite or MySQL with MyISAM tables, there is no
enforced referential integrity; as a result, you may be able to ‘fake’
cross database foreign keys.
}}}
But, foreign keys are enforced at the database level in SQLite, because
[https://github.com/django/django/blob/main/django/db/backends/sqlite3/base.py#L200
the PRAGMA] is turned on.

Should this comment be updated?
--
Ticket URL: <https://code.djangoproject.com/ticket/35156>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 30, 2024, 5:43:09 PM1/30/24
to django-...@googlegroups.com
#35156: Update Doc comment about SQLite foreign keys
-------------------------------+------------------------------------

Reporter: bcail | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Baptiste Mispelon):

* stage: Unreviewed => Accepted

Comment:

Hi,

It seems you might be correct. The paragraph of documentation you linked
to was introduced 14 years ago with #13316, whereas FK constraint were
turned on in sqlite only 7 years ago with #14204 (I found that using the
"blame" feature on github).

So we should fix this, but that leaves me with two questions:

1) Is the comment about MyISAM tables still correct then?
2) Are there other places in the documentation that could be incorrect
with regards to sqlite and FK constraints?
--
Ticket URL: <https://code.djangoproject.com/ticket/35156#comment:1>

Django

unread,
Jan 31, 2024, 12:06:29 AM1/31/24
to django-...@googlegroups.com
#35156: Update Doc comment about SQLite foreign keys
-------------------------------+------------------------------------
Reporter: bcail | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Comment (by Mariusz Felisiak):

Replying to [comment:1 Baptiste Mispelon]:


> 1) Is the comment about MyISAM tables still correct then?

Yes, it is https://dev.mysql.com/doc/refman/8.3/en/ansi-diff-foreign-
keys.html:

> ''"For storage engines that do not support foreign keys (such as
MyISAM),..."''
--
Ticket URL: <https://code.djangoproject.com/ticket/35156#comment:2>

Django

unread,
Jan 31, 2024, 9:48:35 AM1/31/24
to django-...@googlegroups.com
#35156: Update Doc comment about SQLite foreign keys
-------------------------------+------------------------------------
Reporter: bcail | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Comment (by bcail):

> 2) Are there other places in the documentation that could be incorrect
with regards to sqlite and FK constraints?

I just looked and didn't find any.
--
Ticket URL: <https://code.djangoproject.com/ticket/35156#comment:3>

Django

unread,
Jan 31, 2024, 10:18:23 AM1/31/24
to django-...@googlegroups.com
#35156: Update Doc comment about SQLite foreign keys
-------------------------------+------------------------------------
Reporter: bcail | Owner: bcail
Type: Uncategorized | Status: assigned

Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by bcail):

* owner: nobody => bcail
* status: new => assigned

Comment:

I can open a PR.
--
Ticket URL: <https://code.djangoproject.com/ticket/35156#comment:4>

Django

unread,
Jan 31, 2024, 10:39:09 AM1/31/24
to django-...@googlegroups.com
#35156: Update Doc comment about SQLite foreign keys
-------------------------------+------------------------------------
Reporter: bcail | Owner: bcail
Type: Uncategorized | Status: assigned
Component: Documentation | Version: dev
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 bcail):

* has_patch: 0 => 1

Comment:

[https://github.com/django/django/pull/17803 PR 17803]
--
Ticket URL: <https://code.djangoproject.com/ticket/35156#comment:5>

Django

unread,
Jan 31, 2024, 11:52:30 AM1/31/24
to django-...@googlegroups.com
#35156: Update Doc comment about SQLite foreign keys
-------------------------------------+-------------------------------------
Reporter: bcail | Owner: bcail
Type: | Status: assigned
Cleanup/optimization |

Component: Documentation | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* type: Uncategorized => Cleanup/optimization
* stage: Accepted => Ready for checkin

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

Django

unread,
Jan 31, 2024, 12:35:37 PM1/31/24
to django-...@googlegroups.com
#35156: Update Doc comment about SQLite foreign keys
-------------------------------------+-------------------------------------
Reporter: bcail | Owner: bcail
Type: | Status: closed

Cleanup/optimization |
Component: Documentation | Version: dev
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed

Comment:

In [changeset:"b3dc80682e678b20c89fb2a430c0bc77960a29ac" b3dc8068]:
{{{#!CommitTicketReference repository=""
revision="b3dc80682e678b20c89fb2a430c0bc77960a29ac"
Fixed #35156 -- Removed outdated note about not supporting foreign keys by
SQLite.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35156#comment:7>

Django

unread,
Jan 31, 2024, 12:35:48 PM1/31/24
to django-...@googlegroups.com
#35156: Update Doc comment about SQLite foreign keys
-------------------------------------+-------------------------------------
Reporter: bcail | Owner: bcail
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: dev
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"d28c61b777d69e8be724da9287d2bc74c784b802" d28c61b]:
{{{#!CommitTicketReference repository=""
revision="d28c61b777d69e8be724da9287d2bc74c784b802"
[5.0.x] Fixed #35156 -- Removed outdated note about not supporting foreign
keys by SQLite.

Backport of b3dc80682e678b20c89fb2a430c0bc77960a29ac from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35156#comment:8>

Reply all
Reply to author
Forward
0 new messages