Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

#208: fix soda analyze error on mysql #357

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions packages/mysql/sodasql/dialects/mysql_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ def create_connection(self):
conn = mysql.connector.connect(user=self.username,
password=self.password,
host=self.host,
port=self.port,
database=self.database)
return conn
except Exception as e:
Expand Down Expand Up @@ -861,12 +862,12 @@ def is_time(self, column_type: str):
]

def qualify_table_name(self, table_name: str) -> str:
if table_name in self.reserved_keywords:
if table_name.upper() in self.reserved_keywords:
return f'`{table_name}`'
return table_name

def qualify_column_name(self, column_name: str, source_type: str = None):
if column_name in self.reserved_keywords:
if column_name.upper() in self.reserved_keywords:
return f'`{column_name}`'
return column_name

Expand All @@ -877,6 +878,8 @@ def qualify_regex(self, regex) -> str:
return self.escape_metacharacters(regex)

def sql_expr_regexp_like(self, expr: str, pattern: str):
if expr.upper() in self.reserved_keywords:
expr = f"`{expr}`"
return f"{expr} regexp '{self.qualify_regex(pattern)}'"

def sql_expr_cast_text_to_number(self, quoted_column_name, validity_format):
Expand Down