Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add config for SQLite3 Foreign Keys #6050

Merged
merged 1 commit into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions system/Database/SQLite3/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ class Connection extends BaseConnection
*/
public $escapeChar = '`';

/**
* @var bool Enable Foreign Key constraint or not
*/
protected $foreignKeys = false;

public function initialize()
{
parent::initialize();

if ($this->foreignKeys) {
$this->enableForeignKeyChecks();
}
}

/**
* Connect to the database.
*
Expand Down
10 changes: 7 additions & 3 deletions user_guide_src/source/database/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ default group's configuration settings. The values should be name following this
Explanation of Values:
**********************

============== ===========================================================================================================
=============== ===========================================================================================================
Name Config Description
============== ===========================================================================================================
=============== ===========================================================================================================
**dsn** The DSN connect string (an all-in-one configuration sequence).
**hostname** The hostname of your database server. Often this is 'localhost'.
**username** The username used to connect to the database.
Expand Down Expand Up @@ -140,8 +140,12 @@ Explanation of Values:
**port** The database port number. To use this value you have to add a line to the database config array.

.. literalinclude:: configuration/009.php
**foreignKeys** true/false (boolean) - Whether or not to enable Foreign Key constraint (``SQLite3`` only).

============== ===========================================================================================================
.. important:: SQLite3 Foreign Key constraint is disabled by default.
See `SQLite documentation <https://www.sqlite.org/pragma.html#pragma_foreign_keys>`_.
To enforce Foreign Key constraint, set this config item to true.
=============== ===========================================================================================================

.. note:: Depending on what database platform you are using (MySQL, PostgreSQL,
etc.) not all values will be needed. For example, when using SQLite you
Expand Down