You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which operating systems have you tested for this bug?
Linux
Which server did you use?
cli
Database
SQLite3
What happened?
I was checking whether dropColumn of forge returned false when migrating down. Which always seemed to be the case.
When checking the implementation I noticed that Forge expects from the driver that _alterTable returns a SQL statement to be executed, but in this case SQLite3 will return an empty string, because it runs multiple statements in the background, creating a new temporary table without the specified columns, moving data over and renaming afterwards.
Steps to Reproduce
<?phpdeclare(strict_types=1);
namespaceApp\Database\Migrations;
useCodeIgniter\Database\Exceptions\DatabaseException;
useCodeIgniter\Database\Migration;
classAddAColumnToExistingTableextendsMigration
{
protectedstring$table = 'existing_table';
publicfunctionup(): void
{
$this->forge->addColumn($this->table, [
'column' => ['type' => 'varchar', 'null' => false],
]) or thrownewDatabaseException("Could not add columns to table {$this->table}: " . var_export($this->db->error(), true));
}
publicfunctiondown(): void
{
$this->forge->dropColumn($this->table, 'column')
or thrownewDatabaseException("Could drop column from table {$this->table}: " . var_export($this->db->error(), true));
}
}
Expected Output
None, but the DatabaseException is thrown in the down() method, telling me that no error occured.
But dropColumn() returned false, because the statement is empty.
Anything else?
No response
The text was updated successfully, but these errors were encountered:
mkuettel
added
the
bug
Verified issues on the current code behavior or pull requests that will fix them
label
May 2, 2024
mkuettel
changed the title
Bug(SQLite3): forge->dropColumn seems to always return false.
Bug(SQLite3): Forge::dropColumn() seems to always return false
May 2, 2024
PHP Version
8.3
CodeIgniter4 Version
4.5.1
CodeIgniter4 Installation Method
Composer (as dependency to an existing project)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
cli
Database
SQLite3
What happened?
I was checking whether dropColumn of forge returned false when migrating down. Which always seemed to be the case.
When checking the implementation I noticed that Forge expects from the driver that
_alterTable
returns a SQL statement to be executed, but in this case SQLite3 will return an empty string, because it runs multiple statements in the background, creating a new temporary table without the specified columns, moving data over and renaming afterwards.Steps to Reproduce
Expected Output
None, but the DatabaseException is thrown in the down() method, telling me that no error occured.
But dropColumn() returned false, because the statement is empty.
Anything else?
No response
The text was updated successfully, but these errors were encountered: