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

fix(mysql,mariadb): remove extra FROM from showIndexes #14657

Merged
merged 3 commits into from Jun 19, 2022

Conversation

ephys
Copy link
Member

@ephys ephys commented Jun 17, 2022

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • Does yarn test or yarn test-DIALECT pass with this change (including linting)?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description Of Change

Our implementation of MySQL schemas is very broken. MySQL does not have a concept of 'database', and when you see the word 'database' in the MySQL doc, it actually means what we understand as 'schema' in our codebase (CREATE DATABASE and CREATE SCHEMA are synonymous in MySQL).

This PR also fixes our MySQL implementation of showIndexesQuery.

The query is defined as follows:

SHOW INDEX
  {FROM} tbl_name
  [{FROM} db_name]

Our implementation would generate this:

SHOW INDEX FROM `schema`.`tableName` FROM `databaseName`

Where databaseName is the name of the database from the connection credentials. The problem is that in MySQL, that is actually equivalent to doing this:

SHOW INDEX FROM `databaseName`.`tableName`

Which breaks because there is no schema called databaseName.

This PR fixes this by just removing the FROM `databaseName` part. The schema is already handled by our quoteTable function.

@ephys ephys self-assigned this Jun 17, 2022
@ephys ephys added type: bug dialect: mysql For issues and PRs. Things that involve MySQL (and do not involve all dialects). dialect: mariadb For issues and PRs. Things that involve MariaDB (and do not involve all dialects). labels Jun 17, 2022
@ephys ephys merged commit 0016739 into main Jun 19, 2022
@ephys ephys deleted the ephys/mysql-showindex-schema branch June 19, 2022 09:46
@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2022

🎉 This PR is included in version 7.0.0-alpha.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialect: mariadb For issues and PRs. Things that involve MariaDB (and do not involve all dialects). dialect: mysql For issues and PRs. Things that involve MySQL (and do not involve all dialects). released on @v7 type: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants