Skip to content

Commit d88c6c2

Browse files
committed
fix: OCI8 Forge::modifyColumn() changes behavior to NULL by default
For consistency.
1 parent 00d9b17 commit d88c6c2

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

system/Database/OCI8/Forge.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,17 @@ protected function _alterTable(string $alterType, string $table, $field)
120120
// If a null constraint is added to a column with a null constraint,
121121
// ORA-01451 will occur,
122122
// so add null constraint is used only when it is different from the current null constraint.
123-
$isWantToAddNull = strpos($field[$i]['null'], ' NOT') === false;
124-
$currentNullAddable = $nullableMap[$field[$i]['name']];
123+
// If a not null constraint is added to a column with a not null constraint,
124+
// ORA-01442 will occur.
125+
$wantToAddNull = strpos($field[$i]['null'], ' NOT') === false;
126+
$currentNullable = $nullableMap[$field[$i]['name']];
125127

126-
if ($isWantToAddNull === $currentNullAddable) {
128+
if ($wantToAddNull === true && $currentNullable === true) {
129+
$field[$i]['null'] = '';
130+
} elseif ($field[$i]['null'] === '' && $currentNullable === false) {
131+
// Nullable by default
132+
$field[$i]['null'] = ' NULL';
133+
} elseif ($wantToAddNull === false && $currentNullable === false) {
127134
$field[$i]['null'] = '';
128135
}
129136
}

0 commit comments

Comments
 (0)