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: SQL Targets ignore collation when evaluating column data types #1385

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 4 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions singer_sdk/connectors/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,10 +959,18 @@ def _adapt_column_type(
Raises:
NotImplementedError: if altering columns is not supported.
"""
collation_removed = False
current_type: sqlalchemy.types.TypeEngine = self._get_column_type(
full_table_name, column_name
)

# remove collation if present and save it
if hasattr(current_type, "collation"):
BuzzCutNorman marked this conversation as resolved.
Show resolved Hide resolved
if current_type.collation:
current_type_collation = current_type.collation
setattr(current_type, "collation", None)
collation_removed = True

# Check if the existing column type and the sql type are the same
if str(sql_type) == str(current_type):
# The current column and sql type are the same
Expand All @@ -977,6 +985,11 @@ def _adapt_column_type(
# Nothing to do
return

# Put the collation level back before altering the column
if hasattr(compatible_sql_type, "collation"):
if collation_removed:
setattr(compatible_sql_type, "collation", current_type_collation)

if not self.allow_column_alter:
raise NotImplementedError(
"Altering columns is not supported. "
Expand Down