From 5c2f42f4a13babb79a1d356f5f3817b90c08a220 Mon Sep 17 00:00:00 2001 From: kenjis Date: Fri, 24 Mar 2023 15:23:53 +0900 Subject: [PATCH] fix: OCI8 Forge::modifyColumn() changes behavior to NULL by default For consistency. --- system/Database/OCI8/Forge.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/system/Database/OCI8/Forge.php b/system/Database/OCI8/Forge.php index 514cf99f41f4..5aea55928dbe 100644 --- a/system/Database/OCI8/Forge.php +++ b/system/Database/OCI8/Forge.php @@ -120,11 +120,14 @@ protected function _alterTable(string $alterType, string $table, $field) // If a null constraint is added to a column with a null constraint, // ORA-01451 will occur, // so add null constraint is used only when it is different from the current null constraint. - $isWantToAddNull = strpos($field[$i]['null'], ' NOT') === false; - $currentNullAddable = $nullableMap[$field[$i]['name']]; + $wantToAddNull = strpos($field[$i]['null'], ' NOT') === false; + $currentNullable = $nullableMap[$field[$i]['name']]; - if ($isWantToAddNull === $currentNullAddable) { + if ($wantToAddNull === true && $currentNullable === true) { $field[$i]['null'] = ''; + } elseif ($field[$i]['null'] === '' && $currentNullable === false) { + // Nullable by default + $field[$i]['null'] = ' NULL'; } }