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

More robust MySQL catalog usage detection #366

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

adrianfalleiro
Copy link
Contributor

Summary

The current MySQL catalog detection uses substring match to detect if a query makes use of a USE statement. The usage of substring match is brittle and fails if any part of the statement (other than a comment) has the substring use.

This is problematic as user is a very common table name and gets mistakenly detected.

// Should return `undefined` but returns `"*"`
SqlMethodUtils.doesSetCatalog("select * from user", new MySQLDatabaseDialect()) // => "*"

Description

This PR changes the substring match to a more robust regular expression. I also added a few tests cases.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@crystall-bitquill
Copy link
Contributor

Thanks for your PR!

@crystall-bitquill crystall-bitquill merged commit aa04779 into aws:main Jan 14, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

3 participants