Home > Back-end >  Laravel phpunit tests fails with PDOException: SQLSTATE[HY000]: General error: 1 near "0":
Laravel phpunit tests fails with PDOException: SQLSTATE[HY000]: General error: 1 near "0":

Time:08-13

After a composer update in my Laravel project all my tests fails. My Laravel version is 9.24.0

I use PHPUnit tests in a Docker container on Alpine Linux image (php:8.1-fpm-alpine).

pdo_sqlite and sqlite3 php modules are both enabled and loaded (php -m said).

When I run docker-compose run --rm phpunit I get this result for all my tests:

Domain\Customer\Tests\Address\AddressModelTest::myTestName
Illuminate\Database\QueryException: SQLSTATE[HY000]:
General error: 1 near "0": syntax error (SQL: CREATE TABLE ...

/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:759
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:719
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:545
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:109
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:394
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:241
/var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:338
/var/www/html/database/migrations/2021_11_17_154600_alter_table_modify_content_column_type.php:18
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:482
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:400
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:409
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:210
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/View/Components/Task.php:36
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:740
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:210
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:175
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:118
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:87
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:616
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:99
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php:41
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:651
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:139
/var/www/html/vendor/symfony/console/Command/Command.php:308
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:124
/var/www/html/vendor/symfony/console/Application.php:998
/var/www/html/vendor/symfony/console/Application.php:299
/var/www/html/vendor/symfony/console/Application.php:171
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:102
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:194
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:263
/var/www/html/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:286
/var/www/html/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:465
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:80
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:47
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:22
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:123
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:92
/var/www/html/tests/MultitenancyTestCase.php:34

Caused by
PDOException: SQLSTATE[HY000]: General error: 1 near "0": syntax error

/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:538
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:752
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:719
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:545
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:109
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:394
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:241
/var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:338
/var/www/html/database/migrations/2021_11_17_154600_alter_table_modify_content_column_type.php:18
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:482
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:400
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:409
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:210
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/View/Components/Task.php:36
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:740
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:210
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:175
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:118
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:87
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:616
/var/www/html/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:99
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:36
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php:41
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:93
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:37
/var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:651
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:139
/var/www/html/vendor/symfony/console/Command/Command.php:308
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php:124
/var/www/html/vendor/symfony/console/Application.php:998
/var/www/html/vendor/symfony/console/Application.php:299
/var/www/html/vendor/symfony/console/Application.php:171
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:102
/var/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php:194
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:263
/var/www/html/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:286
/var/www/html/vendor/laravel/framework/src/Illuminate/Testing/PendingCommand.php:465
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithConsole.php:80
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:47
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php:22
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:123
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:92
/var/www/html/tests/MultitenancyTestCase.php:34

UPDATE:

The content of 2021_11_17_154600_alter_table_modify_content_column_type.php file is:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('menu_contents', function (Blueprint $table) {
            $table->mediumText('content')->change();
        }); # this is the 18. line

I tried to downgrade laravel/framework:9.3.0, but itsn't helped.

Any idea how can I fix this?

CodePudding user response:

See here for recent issue in doctrine/dbal https://github.com/doctrine/dbal/issues/5584 rolling back to 3.3.7 resolved my issues.

  • Related