From 170c0e2147eb4c99a5e26786fe587c872d81ace7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Fri, 18 Oct 2024 17:50:12 -0600 Subject: [PATCH 1/2] Add failing test --- tests/core/test_typing.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/core/test_typing.py b/tests/core/test_typing.py index 25d9c68df..219c9a587 100644 --- a/tests/core/test_typing.py +++ b/tests/core/test_typing.py @@ -345,6 +345,10 @@ def test_conform_primitives(): sa.types.DATETIME, ), ({"anyOf": [{"type": "integer"}, {"type": "null"}]}, sa.types.INTEGER), + ( + {"type": ["array", "object", "boolean", "null"]}, + sa.types.VARCHAR, + ), ], ) def test_to_sql_type(jsonschema_type, expected): From 1aa3b3c7061fa42d0bd8441bf78434a62907c9f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Fri, 18 Oct 2024 17:53:09 -0600 Subject: [PATCH 2/2] Prioritize object and array --- singer_sdk/typing.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/singer_sdk/typing.py b/singer_sdk/typing.py index 845f1dcd0..a21447a49 100644 --- a/singer_sdk/typing.py +++ b/singer_sdk/typing.py @@ -1216,6 +1216,12 @@ def to_sql_type( # noqa: PLR0911, C901 Returns: The SQL type. """ + if _jsonschema_type_check(jsonschema_type, ("object",)): + return sa.types.VARCHAR() + + if _jsonschema_type_check(jsonschema_type, ("array",)): + return sa.types.VARCHAR() + if _jsonschema_type_check(jsonschema_type, ("string",)): datelike_type = get_datelike_property_type(jsonschema_type) if datelike_type: @@ -1236,10 +1242,4 @@ def to_sql_type( # noqa: PLR0911, C901 if _jsonschema_type_check(jsonschema_type, ("boolean",)): return sa.types.BOOLEAN() - if _jsonschema_type_check(jsonschema_type, ("object",)): - return sa.types.VARCHAR() - - if _jsonschema_type_check(jsonschema_type, ("array",)): - return sa.types.VARCHAR() - return sa.types.VARCHAR()