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(targets): Quote add-column-ddl with column starting with _ (underscore) based on engine #2583

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion singer_sdk/connectors/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ def get_column_add_ddl(
column_type,
),
)
compiled = create_column_clause.compile(self._engine)
compiled = create_column_clause.compile(self._engine).string
return sa.DDL(
"ALTER TABLE %(table_name)s ADD COLUMN %(create_column_clause)s",
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{"type": "SCHEMA", "stream": "ForecastingTypeToCategory", "schema": {"properties": {"Id": {"type": "string"}, "IsDeleted": {"type": ["null", "boolean"]}, "CreatedDate": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": ["string", "null"]}]}, "CreatedById": {"type": ["null", "string"]}, "LastModifiedDate": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": ["string", "null"]}]}, "LastModifiedById": {"type": ["null", "string"]}, "SystemModstamp": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": ["string", "null"]}]}, "ForecastingTypeId": {"type": ["null", "string"]}, "ForecastingItemCategory": {"type": ["null", "string"]}, "DisplayPosition": {"type": ["null", "integer"]}, "IsAdjustable": {"type": ["null", "boolean"]}, "IsOwnerAdjustable": {"type": ["null", "boolean"]}}, "type": "object", "additionalProperties": false}, "key_properties": ["Id"]}
{"type": "SCHEMA", "stream": "ForecastingTypeToCategory", "schema": {"properties": {"Id": {"type": "string"}, "IsDeleted": {"type": ["null", "boolean"]}, "CreatedDate": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": ["string", "null"]}]}, "CreatedById": {"type": ["null", "string"]}, "LastModifiedDate": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": ["string", "null"]}]}, "LastModifiedById": {"type": ["null", "string"]}, "SystemModstamp": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": ["string", "null"]}]}, "ForecastingTypeId": {"type": ["null", "string"]}, "ForecastingItemCategory": {"type": ["null", "string"]}, "DisplayPosition": {"type": ["null", "integer"]}, "IsAdjustable": {"type": ["null", "boolean"]}, "IsOwnerAdjustable": {"type": ["null", "boolean"]}, "age": {"type": "integer"}, "NewCamelCasedAttribute": {"type": "string"}}, "type": "object", "additionalProperties": false}, "key_properties": ["Id"]}
{"type": "SCHEMA", "stream": "ForecastingTypeToCategory", "schema": {"properties": {"Id": {"type": "string"}, "IsDeleted": {"type": ["null", "boolean"]}, "CreatedDate": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": ["string", "null"]}]}, "CreatedById": {"type": ["null", "string"]}, "LastModifiedDate": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": ["string", "null"]}]}, "LastModifiedById": {"type": ["null", "string"]}, "SystemModstamp": {"anyOf": [{"type": "string", "format": "date-time"}, {"type": ["string", "null"]}]}, "ForecastingTypeId": {"type": ["null", "string"]}, "ForecastingItemCategory": {"type": ["null", "string"]}, "DisplayPosition": {"type": ["null", "integer"]}, "IsAdjustable": {"type": ["null", "boolean"]}, "IsOwnerAdjustable": {"type": ["null", "boolean"]}, "age": {"type": "integer"}, "NewCamelCasedAttribute": {"type": "string"}, "_attribute_startswith_underscore": {"type": "string"}}, "type": "object", "additionalProperties": false}, "key_properties": ["Id"]}
18 changes: 16 additions & 2 deletions tests/samples/test_target_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ def test_sqlite_column_addition(sqlite_sample_target: SQLTarget):
props_a: dict[str, dict] = {"col_a": th.StringType().to_dict()}
props_b = deepcopy(props_a)
props_b["col_b"] = th.IntegerType().to_dict()
schema_msg_a, schema_msg_b = (
props_c = deepcopy(props_b)
props_c["_col_c"] = th.IntegerType().to_dict()
schema_msg_a, schema_msg_b, schema_msg_c = (
{
"type": "SCHEMA",
"stream": test_tbl,
Expand All @@ -191,7 +193,7 @@ def test_sqlite_column_addition(sqlite_sample_target: SQLTarget):
"properties": props,
},
}
for props in [props_a, props_b]
for props in [props_a, props_b, props_c]
)
tap_output_a = "\n".join(
json.dumps(msg)
Expand All @@ -211,8 +213,20 @@ def test_sqlite_column_addition(sqlite_sample_target: SQLTarget):
},
]
)
tap_output_c = "\n".join(
json.dumps(msg)
for msg in [
schema_msg_c,
{
"type": "RECORD",
"stream": test_tbl,
"record": {"col_a": "samplerow2", "col_b": 2, "_col_c": 3},
},
]
)
target_sync_test(sqlite_sample_target, input=StringIO(tap_output_a), finalize=True)
target_sync_test(sqlite_sample_target, input=StringIO(tap_output_b), finalize=True)
target_sync_test(sqlite_sample_target, input=StringIO(tap_output_c), finalize=True)


def test_sqlite_activate_version(
Expand Down
Loading