Skip to content

Conversation

@pkuczynski
Copy link
Collaborator

Drop support for mysql package and default to mysql2. Removes some custom mysql driver logic and props, which does not make sense anymore.

Refs #11692

@pkuczynski pkuczynski self-assigned this Nov 13, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mysql2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 13, 2025

commit: f0b8f3c

@pkuczynski pkuczynski added this to the Next Major milestone Nov 13, 2025
@pkuczynski pkuczynski moved this to In Progress in TypeORM Roadmap Nov 13, 2025
@gioboa gioboa requested review from OSA413 and alumni November 13, 2025 17:01
@alumni
Copy link
Collaborator

alumni commented Nov 13, 2025

Nice!

Can you check if there's something related to authentication that can be removed? I remember that was the main change in the mysql2 client. MySQL itself deprecated and later dropped support for old auth methods, but MariaDB and cloud versions of MySQL (AWS / Alibaba) might still use the old authentication.

Another thing we might need to do is to flip the default for legacy spatial support to false (i.e. remove it from connection options in MysqlDriver.connect).

@pkuczynski
Copy link
Collaborator Author

Can you check if there's something related to authentication that can be removed? I remember that was the main change in the mysql2 client. MySQL itself deprecated and later dropped support for old auth methods, but MariaDB and cloud versions of MySQL (AWS / Alibaba) might still use the old authentication.

I did not used mysql for many years not, so do not have the details. Can you point me to what exactly do you mean or maybe to some documentation? I also added it to the list in #11692, so it does not get forgotten.

Another thing we might need to do is to flip the default for legacy spatial support to false (i.e. remove it from connection options in MysqlDriver.connect).

This is already added to #11692

I would suggest we merge it as it is, and I will tackle remaning two points in separate PRs. I would also need some help since my knowledge of mysql is quite limited. I am typically using pg

@OSA413
Copy link
Collaborator

OSA413 commented Nov 16, 2025

Looks fine but needs testing.

Btw my ultimate-test-suite broke when trying to pull this PR, I will check that later.

@pkuczynski
Copy link
Collaborator Author

Btw my ultimate-test-suite broke when trying to pull this PR, I will check that later.

Can you share your test suite? And why it is not part of the repo?

@OSA413
Copy link
Collaborator

OSA413 commented Nov 17, 2025

Can you share your test suite?

https://github.com/OSA413/typeorm-ultimate-test-suite

And why it is not part of the repo?

Because 1) it's my initiative, 2) it's in WIP state, 3) the dataset is very huge and 4) no one else took the initiative to help (but that's ok). I'm currently not considering including it into the main repo because it can be unstable (and you need some time to understand what's going on there). I personally use the test suite as a canary to test PRs I'm reviewing.

@pkuczynski
Copy link
Collaborator Author

Because 1) it's my initiative, 2) it's in WIP state, 3) the dataset is very huge and 4) no one else took the initiative to help (but that's ok). I'm currently not considering including it into the main repo because it can be unstable (and you need some time to understand what's going on there). I personally use the test suite as a canary to test PRs I'm reviewing.

Thanks for sharing. The dataset is quite large, but rest does not seem extensively big. Yet it's indeed a but hard to grasp on the first look. And if the overal stability of the suite is in question, than indeed it's hard to rely on it.

Let me know what does your investigation brings as from my point of view this PR is ready to be merged.

@OSA413
Copy link
Collaborator

OSA413 commented Nov 17, 2025

Would this be a blocker to dropping support of mysql?

@pkuczynski
Copy link
Collaborator Author

Would this be a blocker to dropping support of mysql?

Not necessarily. There is a #11274 PR which should fix it, so we should maybe work on this one too?

@OSA413
Copy link
Collaborator

OSA413 commented Nov 17, 2025

There is a #11274 PR which should fix it

I don't think this will fix the issue with truncated error log

@pkuczynski
Copy link
Collaborator Author

@alumni @OSA413 what should we do about this then?

@pkuczynski
Copy link
Collaborator Author

I don't think this will fix the issue with truncated error log

Sorry, I meant to point to #11273 not #11274... Looks like the original author have not time to work on it, so I can take it over if you think its worth it? And given @alumni initial approval it probably is.

@OSA413
Copy link
Collaborator

OSA413 commented Nov 20, 2025

it's worth it, you probably should continue working in the PR's branch and carry it to the point of it being good enough to merge into master (I haven't checked what's the solution to the problem with the truncated log)

@alumni
Copy link
Collaborator

alumni commented Nov 20, 2025

I don't think #11273 is related in any way to this PR (besides affecting the same driver). There were some changes in the all drivers (including MySQL) related to event handling - that's why it has some merge conflicts - I wanted to fix and merge that PR since author is busy, but realized might take more than 5-10 min to fix the conflict. Feel free to check if you have the time (you can ignore my comment there about a promisify-like helper, it was just a suggestion).

I don't work with MySQL/MariaDB on a daily basis either, but if I change things I try to understand how they work before making the change.

For this PR, I would remove the legacy spatial support as default and put this information (and the client change) in some "migration guide" doc page (in the Guides section). Regarding auth, I would check how it works, but likely there's not much to remove, it was just a heads up that there is something that we should check (these things will not be done by code reviewers).

@alumni alumni mentioned this pull request Dec 3, 2025
26 tasks
# Conflicts:
#	README-zh_CN.md
#	README_ko.md
#	package-lock.json
#	package.json
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 5, 2025

Deploying typeorm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9935523
Status: ✅  Deploy successful!
Preview URL: https://c3205813.typeorm.pages.dev
Branch Preview URL: https://mysql2.typeorm.pages.dev

View logs

@qodo-free-for-open-source-projects
Copy link

qodo-free-for-open-source-projects bot commented Dec 5, 2025

PR Code Suggestions ✨

Latest suggestions up to f0b8f3c

CategorySuggestion                                                                                                                                    Impact
Possible issue
Validate loaded driver is not empty

Validate that the loaded mysql2 driver is not an empty object. This restores a
check that was removed to handle module resolution issues in environments like
Jest.

src/driver/mysql/MysqlDriver.ts [1177-1183]

 protected loadDependencies(): void {
     try {
         this.mysql = this.options.driver || PlatformTools.load("mysql2")
+        if (Object.keys(this.mysql).length === 0) {
+            throw new DriverPackageNotInstalledError("Mysql", "mysql2")
+        }
     } catch (e) {
         throw new DriverPackageNotInstalledError("Mysql", "mysql2")
     }
 }
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The PR removed a check for an empty module object, which was originally added to handle module resolution issues in environments like Jest. Re-introducing this check for mysql2 is a crucial defensive measure to prevent potential runtime errors, improving the robustness of the driver loading mechanism.

Medium
  • More

Previous suggestions

✅ Suggestions up to commit c155f8a
CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix malformed error message template
Suggestion Impact:The commit directly implements the suggestion by removing the malformed template literal with the extra `}` character and fixing the indentation. The error message now correctly reads "MySQL connection raised an error. ${error}" instead of the broken multi-line version with the extraneous closing brace.

code diff:

-                    `
-        }MySQL connection raised an error. ${error}`,
+                    `MySQL connection raised an error. ${error}`,

Fix the malformed template literal in the error handler by removing an
extraneous closing brace and incorrect indentation.

src/driver/mysql/MysqlDriver.ts [1268-1274]

 connection.on("error", (error: any) =>
     logger.log(
         "warn",
-        `
-    }MySQL connection raised an error. ${error}`,
+        `MySQL connection raised an error. ${error}`,
     ),
 )
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a syntax error in the PR, where a template literal for an error message is malformed with an extra } character, which would break the error handling logic.

High
✅ Suggestions up to commit ea41136
CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix malformed template string
Suggestion Impact:The commit directly implements the suggestion by removing the malformed template string formatting. The extraneous closing brace and extra whitespace were removed, and the template string was corrected to be on a single line as suggested.

code diff:

-                    `
-        }MySQL connection raised an error. ${error}`,
+                    `MySQL connection raised an error. ${error}`,

Correct the malformed template string in the error log message by removing an
extraneous closing brace and extra whitespace.

src/driver/mysql/MysqlDriver.ts [1268-1274]

 connection.on("error", (error: any) =>
     logger.log(
         "warn",
-        `
-    }MySQL connection raised an error. ${error}`,
+        `MySQL connection raised an error. ${error}`,
     ),
 )
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a malformed template string in a log message, which includes an extraneous closing brace and incorrect formatting, likely introduced by mistake in the PR.

Medium
Suggestions up to commit 9935523
CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix malformed error message template
Suggestion Impact:The commit directly implements the suggestion by removing the malformed template literal with the extra `}` character and fixing the indentation. The error message now correctly reads "MySQL connection raised an error. ${error}" instead of the broken multi-line version with the extraneous closing brace.

code diff:

-                    `
-        }MySQL connection raised an error. ${error}`,
+                    `MySQL connection raised an error. ${error}`,

Fix the malformed template literal in the MySQL error log message to ensure the
output is correctly formatted and does not contain a stray closing brace.

src/driver/mysql/MysqlDriver.ts [1268-1274]

 connection.on("error", (error: any) =>
     logger.log(
         "warn",
-        `
-    }MySQL connection raised an error. ${error}`,
+        `MySQL connection raised an error. ${error}`,
     ),
 )
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies a malformed template literal in an error log message, which was likely introduced by mistake and would lead to confusing and incorrect log output.

Low

@coveralls
Copy link

coveralls commented Dec 7, 2025

Coverage Status

coverage: 80.797% (+0.03%) from 80.769%
when pulling f0b8f3c on mysql2
into ef9e4b6 on next.

Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, did you use find replace approach?

@pkuczynski
Copy link
Collaborator Author

It looks good, did you use find replace approach?

No, search and manual replace/changes. Why do you ask?

Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity 😅😂

Copy link
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me, thank you @pkuczynski

@pkuczynski pkuczynski merged commit 14e2ae3 into next Dec 8, 2025
62 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in TypeORM Roadmap Dec 8, 2025
@pkuczynski pkuczynski deleted the mysql2 branch December 8, 2025 20:16
alumni added a commit to alumni/typeorm that referenced this pull request Dec 12, 2025
typeorm#11766)

Co-authored-by: Lucian Mocanu <alumni@users.noreply.github.com>
alumni added a commit to alumni/typeorm that referenced this pull request Dec 12, 2025
typeorm#11766)

Co-authored-by: Lucian Mocanu <alumni@users.noreply.github.com>
alumni added a commit to alumni/typeorm that referenced this pull request Dec 12, 2025
typeorm#11766)

Co-authored-by: Lucian Mocanu <alumni@users.noreply.github.com>
mgohin pushed a commit to mgohin/typeorm that referenced this pull request Jan 15, 2026
typeorm#11766)

Co-authored-by: Lucian Mocanu <alumni@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants