Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
handling fields >8000 char
Browse files Browse the repository at this point in the history
  • Loading branch information
radbrt committed Jan 19, 2023
1 parent 1fe90c5 commit 25d1359
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions target_mssql/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,15 @@ def to_sql_type(self, jsonschema_type: dict) -> sqlalchemy.types.TypeEngine: #
if datelike_type == "date":
return cast(sqlalchemy.types.TypeEngine, sqlalchemy.types.DATE())

maxlength = jsonschema_type.get("maxLength") or 8000
target_length = min(maxlength, 8000)
maxlength = jsonschema_type.get("maxLength")
if maxlength is not None:
if maxlength > 8000:
return cast(
sqlalchemy.types.TypeEngine, sqlalchemy.types.TEXT()
)

return cast(
sqlalchemy.types.TypeEngine, sqlalchemy.types.VARCHAR(target_length)
sqlalchemy.types.TypeEngine, sqlalchemy.types.VARCHAR(maxlength)
)

if self._jsonschema_type_check(jsonschema_type, ("integer",)):
Expand Down
2 changes: 1 addition & 1 deletion target_mssql/sinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def merge_upsert_from_table(

self.connection.execute(merge_sql)

# self.connection.execute("COMMIT")
self.connection.execute("COMMIT")

def parse_full_table_name(
self, full_table_name: str
Expand Down
3 changes: 3 additions & 0 deletions target_mssql/tests/data_files/long_string.singer
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"type": "SCHEMA", "stream": "long_string", "schema": {"type": "object", "properties": { "CustomerID": {"type": "string", "maxlength": 12000}, "clientName": {"type": "string"} }}, "key_properties": ["CustomerID"]}
{"type": "RECORD", "stream": "long_string", "record": {"CustomerID": "1", "clientName": "Gitter Windows Desktop App"}}
{"type": "RECORD", "stream": "long_string", "record": {"CustomerID": "2", "clientName": "Gitter iOS App"}}

0 comments on commit 25d1359

Please sign in to comment.