New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing/renaming/dropping columns on sqlite doesn't work in v 3.4.x #5584
Comments
Hi @oraslaci This has been raised and merged in, just waiting on them to release a 4.0.1. For now we have rolled back to 3.3.7 |
@GlitchWitch it doesn't look like your locked version of
|
@morozov I did run This caused the following to get added to the lock file.
|
According to the above output, you're using commit 118a360 which is the |
Yeah, I just realised that. I'm not sure why setting I've just tested by manually changing the lock file to use the latest commit 564edcd. Edit: that seems to solve it and things are back to normal. 👍 |
Thanks for the confirmation, @GlitchWitch. |
Hello, I tried out the newly released version 3.4.1 and it isn't fixed on my side. On version 3.3.x all went good. The error message is:
My composer.lock file is: {
"name": "doctrine/dbal",
"version": "3.4.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal.git",
"reference": "94e016428884227245fb1219e0de7d8b86ca16d7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/94e016428884227245fb1219e0de7d8b86ca16d7",
"reference": "94e016428884227245fb1219e0de7d8b86ca16d7",
"shasum": ""
},
}
Steps for reproduction: 1.) New Laravel project with doctrine <env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/> 5.) Add the following code in to your TestCase.php (This adds supports for dropping foreign keys before version 3.4.x) use CreatesApplication, RefreshDatabase;
public function __construct(?string $name = null, array $data = [], $dataName = '')
{
$this->hotfixSqlite();
parent::__construct($name, $data, $dataName);
}
/**
* Fix for: BadMethodCallException : SQLite doesn't support dropping foreign keys (you would need to re-create the table).
*/
public function hotfixSqlite()
{
Connection::resolverFor('sqlite', function ($connection, $database, $prefix, $config) {
return new class($connection, $database, $prefix, $config) extends SQLiteConnection
{
public function getSchemaBuilder()
{
if ($this->schemaGrammar === null) {
$this->useDefaultSchemaGrammar();
}
return new class($this) extends SQLiteBuilder
{
protected function createBlueprint($table, \Closure $callback = null)
{
return new class($table, $callback) extends Blueprint
{
public function dropForeign($index)
{
return new Fluent();
}
};
}
};
}
};
});
} 6.) Run the ExampleTest from the tests/Feature directory. Here is a link to an example repository The output for the dd from the variables
Because it is a memory sqlite database maybe that can be the issue. |
I can also confirm that the issue still persists. I did make sure I have the correct |
Thanks for the reproducer, @schonhoff. I should be able to debug the regular expression and question and hopefully adjust it to work properly with the DDL in question. |
There is a pending pull request that should address this issue (#5597). Please provide your feedback if you can test it in your environments. |
I did the change myself in my project and it worked like intended. Maybe another person can confirm it? |
Yep, I manually did the change as well and it's all good and well. Thank you ! 🙌 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug Report
Summary
I ran into the issue while running migrations in laravel 9.0, which uses docrine/dbal behind the curtains.
Any kind of change (dropColumn, renameColumn, change) to columns on sqlite db, throws an error
Current behaviour
Migrations throw an exception:
ErrorException
Undefined array key -1
I traced the issue to this function, where the regex fails to match what createSql returns
Somehow the regex fails to match the following
How to reproduce
Expected behaviour
The migration should run w/o a problem.
Workaround:
Installed "doctrine/dbal": "^2.13.3" and it works w/o a problem.
The text was updated successfully, but these errors were encountered: