Skip to content
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

Databases not being created when using parallel testing #39711

Closed
Livijn opened this issue Nov 20, 2021 · 2 comments
Closed

Databases not being created when using parallel testing #39711

Livijn opened this issue Nov 20, 2021 · 2 comments

Comments

@Livijn
Copy link
Contributor

Livijn commented Nov 20, 2021

  • Laravel Version: 8.73
  • PHP Version: 8
  • Database Driver & Version: MySQL 8

Description:

When I run php artisan test --parallel I get an exception:

Doctrine\DBAL\Driver\PDO\Exception: SQLSTATE[HY000] [1049] Unknown database 'xxx_test_1'

My tests can run if I create the databases manually. So I looked into the source to see where it goes wrong. What I found was that this try/catch block is where something is messed up (for me at least). It seems like Laravel tries to use a database, and whenever it stumbles upon an exception it assumes that it should recreate the database.

However, for me, the exception that is thrown is of another type: Doctrine\DBAL\Driver\PDO\Exception not Illuminate\Database\QueryException. So if I change that catch-handler to the right exception type it works.

try {
$this->usingDatabase($testDatabase, function () {
Schema::hasTable('dummy');
});
} catch (QueryException $e) {
$this->usingDatabase($database, function () use ($testDatabase) {
Schema::dropDatabaseIfExists($testDatabase);
Schema::createDatabase($testDatabase);
});
return [$testDatabase, true];
}

Why is this happening? Is there something I've missed in an earlier Laravel upgrade? Or is it a bug?

@driesvints
Copy link
Member

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to open up a new issue with a link to the original one and we'll gladly help you out.

Thanks!

@Livijn
Copy link
Contributor Author

Livijn commented Nov 21, 2021

So, I've tried to pin point the reason for this behavior. I found that this happens when requiring these two packages in a brand new Laravel installation:

"doctrine/dbal": "^2.8",
"grimzy/laravel-mysql-spatial": "^5.0",

I'm pretty sure its the laravel-mysql-spatial that is causing these issues. Something similar stated here: grimzy/laravel-mysql-spatial#178

Edit: Found this issue which states the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants