Skip to content

Commit

Permalink
refactor: by rector
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Mar 24, 2023
1 parent a32a1b2 commit e8e7a6b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions system/Database/Postgre/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ protected function _alterTable(string $alterType, string $table, $field)
}

$nullable = true; // Nullable by default.
if (isset($data['null'])) {
if ($data['null'] === false || $data['null'] === ' NOT ' . $this->null) {
$nullable = false;
}
if (isset($data['null']) && ($data['null'] === false || $data['null'] === ' NOT ' . $this->null)) {
$nullable = false;
}
$sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escapeIdentifiers($data['name'])
. ($nullable === true ? ' DROP' : ' SET') . ' NOT NULL';
Expand Down
6 changes: 2 additions & 4 deletions system/Database/SQLSRV/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,8 @@ protected function _alterTable(string $alterType, string $table, $field)
}

$nullable = true; // Nullable by default.
if (isset($data['null'])) {
if ($data['null'] === false || $data['null'] === ' NOT ' . $this->null) {
$nullable = false;
}
if (isset($data['null']) && ($data['null'] === false || $data['null'] === ' NOT ' . $this->null)) {
$nullable = false;
}
$sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escapeIdentifiers($data['name'])
. " {$data['type']}{$data['length']} " . ($nullable === true ? '' : 'NOT') . ' NULL';
Expand Down

0 comments on commit e8e7a6b

Please sign in to comment.