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

Wrong MySQL platform is being returned by the TracingDriverForV32 #734

Closed
SanderVerkuil opened this issue Jun 19, 2023 · 10 comments
Closed
Assignees

Comments

@SanderVerkuil
Copy link

SanderVerkuil commented Jun 19, 2023

Environment

What version are you running? Etc.

  • php: PHP 8.2.7
  • symfony: 5.4
  • sentry/sentry-symfony: 4.9.1
  • doctrine/dbal: 3.6.3
  • doctrine/orm: 2.15.2

Steps to Reproduce

  1. Run bin/console doctrine:schema:update --complete --dump-sql.

Expected Result

The command should succeed

Actual Result

An exception occurred that the platform does not support the json type.


When building the connection, doctrine is fetching the DatabasePlatform. This calls the detectDatabasePlatform method, which chooses whether it will call the method createDatabasePlatformForVersion or the method getDatabasePlatform.

The version is fetched with the method getDatabasePlatformVersion(). If the driver is not an instance of the VersionAwarePlatformDriver interface, it always returns null, which then calls the getDatabasePlatform method, which returns the default MySqlPlatform, which does not support the json type.

It should have returned the MySQL80Platform in my case.

The fix appears to be as simple as implementing the VersionAwarePlatformDriver on the TracingDriverForV32 class, but in this comment the choice was made to not implement the deprecated interface, which makes sense.

Though I do not fully understand why the VersionAwarePlatformDriver was deprecated, as the comment itself says that All drivers will have to be aware of the server version in the next major release., which leads me to believe that as of the next major version of the doctrine/dbal, the createDatabasePlatformForVersion will be moved to the Driver interface... This makes sense, but then the TracingDriverForV32 should still implement the VersionAwarePlatformDriver right? At least until the next major version?

@cleptric
Copy link
Member

We fixed this in #731, with version 4.9.1 being released today that contains the change. TracingDriverForV32 does contain createDatabasePlatformForVersion now, but we did not implement the interface to fix triggering deprecation warnings (See #579).

So to confirm, you already updated to 4.9.1, and the issue persists?

@cleptric
Copy link
Member

Ok, so I understand we should also add getDatabasePlatform, correct?

@SanderVerkuil
Copy link
Author

Yes, I've updated to 4.9.1 and the issue persists. The reason is that the Connection class calls either the createDatabasePlatformForVersion or the getDatabasePlatform method. As the version is set to null, because the driver is not an instance of the VersionAwarePlatformDriver, the method getDatabasePlatform is called, which returns the MySQLPlatform, instead of the MySQL80Platform.

@SanderVerkuil
Copy link
Author

The TracingDriverForV3 does implement the VersionAwarePlatformDriver, which ensures that the correct method is called, but the TracingDriverForV32 is not called.

This might be an issue in the doctrine/dbal though, that the VersionAwarePlatformDriver should not have been made deprecated just yet, as it is still required for the correct functioning of the system.

The getDatabasePlatform is already present, but that returns the MySQLPlatform according the the AbstractMySQLDriver. The only correct way I see is to let the TracingDriverForV32 implement the VersionAwarePlatformDriver, which will trigger deprecations again, but I think that those deprecations just aren't correct 🤷

@ste93cry
Copy link
Collaborator

ste93cry commented Jun 19, 2023

I tried looking at the changes that have been made in the DBAL in the next future major version (4.0) and as far as I see, the way this deprecation has been handled is a real mess:

To me, there is something missing for a deprecation-free and clean upgrade path from version 3.x to version 4.0 of the DBAL. But, there is also another thing to say: this deprecation is actually not triggered by the Doctrine package; as I said for similar other deprecations, this is PHPUnit Bridge not minding its own business and triggering notices all around as soon as it sees a @deprecation tag. Maybe we should revert all the changes and just tell everyone to suppress this deprecation using the baseline.

@morozov since you are the original author of the changes in the DBAL, can you give us some hints on how you envisioned the upgrade path?

@cleptric
Copy link
Member

Maybe we should revert all the changes and just tell everyone to suppress this deprecation using the baseline.

I would like to go this route for now. I rather have some deprecation warnings than a broken SDK. I'll get the PR ready.

@cleptric
Copy link
Member

@ste93cry Mind copying your comment over to #579? I reopened the issue.

@SanderVerkuil This issue was fixed in 4.9.2, sorry for the trouble!

@ruudk
Copy link
Contributor

ruudk commented Jun 19, 2023

Maybe we should revert all the changes and just tell everyone to suppress this deprecation using the baseline.

@ste93cry FWIW, the baseline doesn't work when you run tests in random order.

@SanderVerkuil
Copy link
Author

@cleptric Yep, it has indeed been fixed! Thanks for the quick iteration and fast feedback ❤️

@morozov
Copy link

morozov commented Jun 19, 2023

@ste93cry if you believe that there is an upgrade issue that might/should be addressed in the DBAL, please file an issue with doctrine/dbal and provide the relevant details there.

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

No branches or pull requests

5 participants