From a32a1b2720e5e7632e60a8ac07059b8f5316461d Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 23 Mar 2023 17:10:56 +0900 Subject: [PATCH] docs: add note for modifyColumn() --- user_guide_src/source/dbmgmt/forge.rst | 9 +++++++++ user_guide_src/source/dbmgmt/forge/026.php | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/dbmgmt/forge.rst b/user_guide_src/source/dbmgmt/forge.rst index bfb3bca9aea1..17a376b77f0d 100644 --- a/user_guide_src/source/dbmgmt/forge.rst +++ b/user_guide_src/source/dbmgmt/forge.rst @@ -294,6 +294,15 @@ change the name, you can add a "name" key into the field defining array. .. literalinclude:: forge/026.php +.. note:: The ``modifyColumn()`` may unexpectedly change ``NULL``/``NOT NULL``. + So it is recommended to always specify ``null`` value. + +.. note:: Due to a bug, prior v4.3.3, SQLite3 may not set ``NOT NULL`` even if you + specify ``'null' => false``. + +.. note:: Due to a bug, prior v4.3.3, Postgres and SQLSRV set ``NOT NULL`` even + if you specify ``'null' => false``. + .. _db-forge-adding-keys-to-a-table: Adding Keys to a Table diff --git a/user_guide_src/source/dbmgmt/forge/026.php b/user_guide_src/source/dbmgmt/forge/026.php index bd923d8a6ec0..be597f058b0b 100644 --- a/user_guide_src/source/dbmgmt/forge/026.php +++ b/user_guide_src/source/dbmgmt/forge/026.php @@ -4,7 +4,8 @@ 'old_name' => [ 'name' => 'new_name', 'type' => 'TEXT', + 'null' => false, ], ]; $forge->modifyColumn('table_name', $fields); -// gives ALTER TABLE `table_name` CHANGE `old_name` `new_name` TEXT +// gives ALTER TABLE `table_name` CHANGE `old_name` `new_name` TEXT NOT NULL