Skip to content

Commit

Permalink
fix: OCI8 Forge::modifyColumn() changes behavior to NULL by default
Browse files Browse the repository at this point in the history
For consistency.
  • Loading branch information
kenjis committed Mar 24, 2023
1 parent e8e7a6b commit 5c2f42f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions system/Database/OCI8/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}

Expand Down

0 comments on commit 5c2f42f

Please sign in to comment.