Skip to content

Commit a8cfb51

Browse files
committed
fix: fix the return type of dropColumn function.
1 parent 2b3b8ed commit a8cfb51

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

system/Database/Forge.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,11 @@ public function dropColumn(string $table, $columnNames)
796796
return false;
797797
}
798798

799+
// If _alterTable() return execute result instead of sql string, return.
800+
if ((bool) $sql === true) {
801+
return true;
802+
}
803+
799804
return $this->db->query($sql);
800805
}
801806

system/Database/SQLite3/Forge.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,12 @@ protected function _alterTable(string $alterType, string $table, $processedField
126126

127127
$sqlTable = new Table($this->db, $this);
128128

129-
$sqlTable->fromTable($table)
129+
$sqlExecuteResult = $sqlTable->fromTable($table)
130130
->dropColumn($columnNamesToDrop)
131131
->run();
132132

133-
return ''; // Why empty string?
133+
// Return the execute result with string type.
134+
return '' . $sqlExecuteResult;
134135

135136
case 'CHANGE':
136137
$fieldsToModify = [];

tests/system/Database/Live/ForgeTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,8 @@ public function testDropColumn(): void
13171317

13181318
$this->assertTrue($this->db->fieldExists('name', 'forge_test_two'));
13191319

1320-
$this->forge->dropColumn('forge_test_two', 'name');
1320+
$result = $this->forge->dropColumn('forge_test_two', 'name');
1321+
$this->assertTrue($result);
13211322

13221323
$this->db->resetDataCache();
13231324

0 commit comments

Comments
 (0)