LiipTestFixturesBundle icon indicating copy to clipboard operation
LiipTestFixturesBundle copied to clipboard

[Doc] Schema creation with doctrine/orm < or > 2.6

Open magnetik opened this issue 6 years ago • 4 comments

Hi,

The doc for 2.x states:

The Bundle will not automatically create your schema for you unless you use SQLite or use doctrine/orm < 2.6.

But a few lines later, the option to resolve it is: composer require doctrine/orm:^2.6

So this should be "The bundle will not automatically create your schema for you unless you use SQLite or doctrine/orm >= 2.6" ?

magnetik avatar Mar 19 '19 13:03 magnetik

And I just tried with doctrine/orm 2.6.4, and the loadFixtures() fails with Unknown database error because it tries to select it as soon as the connection is started, so before the createDatgabaseIfNotExists() call of the bundle.

magnetik avatar Mar 19 '19 13:03 magnetik

Thanks for your test, so it worked with doctrine/orm 2.6.3?

doctrine/orm:^2.6 is already required in require-dev of composer.json of the 2.x branch, so internal tests use latest version while users can use an older one.

(using a lower ORM version may explain liip/LiipFunctionalTestBundle#470 and/or liip/LiipFunctionalTestBundle#423 and why I wasn't able to reproduce the errors, it needs further investigation)

alexislefebvre avatar Mar 19 '19 22:03 alexislefebvre

My bad I was testing with doctrine 2.6.3.

BUT good news, I think I have it !

I was using a database URL with the database name inside (mysql://[email protected]:3306/bar). The ORMDatabaseTools removes the dbname from the params but not from the URL, hence it's trying to do a connection to the database to create the database.

I'll see if I can come up with a not-so-bad PR.

magnetik avatar Mar 20 '19 08:03 magnetik

Well I'm not that clever.

Maybe we can just remove the path of the URL with some parse_url, but I fear that this would lead to some breakage with sqlite.

It seems very dirty to try to handle the URL has good as doctrine DriverManager does, and all it's methods are private so we cannot really rely on it.

Maybe we can just issue a warning stating that the URL should not be used?

magnetik avatar Mar 20 '19 08:03 magnetik