Replace mysql
client with mysql2
#22534
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Scope
Replace the database client library
mysql
withmysql2
, which is a continuation of the former. The client is used to connect to MySQL/MariaDB databases.Besides
mysql2
being actively maintained, it also promises better performance along with additional features.Switching to
mysql2
enables using MySQL without themysql_native_password
authentication plugin, deprecated in MySQL 8.0.34 1.mysql2
is a drop in replacement formysql
, with two known incompatibilities 2 (see below).Potential Risks / Drawbacks
As mentioned in the breaking changes:
mysql2
leads to cross-collection queries (filtering on relations) with stricter charset comparison, meaning the value ofDB_CHARSET
/DB_CHARSET_NUMBER
needs to match the charset of the tables to work properly. This has already been recommended before and a corresponding warning in the server log has already been in place.string
instead of anumber
, which ensures that the precision is preserved. This matches the behavior of PostgreSQL.Review Notes / Questions
As you can see in https://github.com/directus/directus/actions/runs/9478259269, the blackbox tests are successful (only the checks fail, which are generally an issue at the moment)
Closes #19361, related to #20502
Footnotes
https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-34.html ↩
https://sidorares.github.io/node-mysql2/docs/documentation#known-incompatibilities-with-node-mysql ↩