Skip to content

Commit fbecc0e

Browse files
committed
fix: Postgres Forge::modifyColumn() changes NULL incorrectly
1 parent 099a495 commit fbecc0e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

system/Database/Postgre/Forge.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,14 @@ protected function _alterTable(string $alterType, string $table, $field)
109109
. " SET DEFAULT {$data['default']}";
110110
}
111111

112+
$nullable = true; // Nullable by default.
112113
if (isset($data['null'])) {
113-
$sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escapeIdentifiers($data['name'])
114-
. ($data['null'] === true ? ' DROP' : ' SET') . ' NOT NULL';
114+
if ($data['null'] === false || $data['null'] === ' NOT ' . $this->null) {
115+
$nullable = false;
116+
}
115117
}
118+
$sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escapeIdentifiers($data['name'])
119+
. ($nullable === true ? ' DROP' : ' SET') . ' NOT NULL';
116120

117121
if (! empty($data['new_name'])) {
118122
$sqls[] = $sql . ' RENAME COLUMN ' . $this->db->escapeIdentifiers($data['name'])

0 commit comments

Comments
 (0)