Skip to content

Commit fa8643b

Browse files
committed
fix: SQLSRV Forge::modifyColumn() changes NULL incorrectly
1 parent 50133d5 commit fa8643b

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

system/Database/SQLSRV/Forge.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,14 @@ protected function _alterTable(string $alterType, string $table, $field)
203203
. " DEFAULT {$data['default']} FOR " . $this->db->escapeIdentifiers($data['name']);
204204
}
205205

206+
$nullable = true; // Nullable by default.
206207
if (isset($data['null'])) {
207-
$sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escapeIdentifiers($data['name'])
208-
. ($data['null'] === true ? ' DROP' : '') . " {$data['type']}{$data['length']} NOT NULL";
208+
if ($data['null'] === false || $data['null'] === ' NOT ' . $this->null) {
209+
$nullable = false;
210+
}
209211
}
212+
$sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escapeIdentifiers($data['name'])
213+
. " {$data['type']}{$data['length']} " . ($nullable === true ? '' : 'NOT') . ' NULL';
210214

211215
if (! empty($data['comment'])) {
212216
$sqls[] = 'EXEC sys.sp_addextendedproperty '

0 commit comments

Comments
 (0)