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 when use lower_case_table_names 0 in mysql #2524

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions redash/query_runner/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ def enabled(cls):

def _get_tables(self, schema):
query = """
SELECT col.table_schema,
col.table_name,
col.column_name
SELECT col.TABLE_SCHEMA as table_schema,
col.TABLE_NAME as table_name,
col.COLUMN_NAME as column_name
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this breaking for anyone who didn't set local_case_table_names to 0?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll answer instead: no, it will not, because originally all column names in information_schema are upper-cased. When lower_case_table_names == 0 - then query must use upper-cased names as well; when lower_case_table_names != 0 - no matter what case the query use, MySQL will use CI comparison. So common denominator is to always use upper-cased names.

FROM `information_schema`.`columns` col
WHERE col.table_schema NOT IN ('information_schema', 'performance_schema', 'mysql');
WHERE col.TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql');
"""

results, error = self.run_query(query, None)
Expand Down