diff --git a/tap_postgres/client.py b/tap_postgres/client.py index 90dfdf78..fec3351b 100644 --- a/tap_postgres/client.py +++ b/tap_postgres/client.py @@ -2,6 +2,7 @@ This includes PostgresStream and PostgresConnector. """ + from __future__ import annotations import datetime @@ -123,7 +124,17 @@ def to_jsonschema_type( type_name = type(sql_type).__name__ if type_name is not None and type_name in ("JSONB", "JSON"): - return {} + return { + "type": [ + "string", + "number", + "integer", + "object", + "array", + "boolean", + "null", + ], + } if ( type_name is not None diff --git a/tests/test_core.py b/tests/test_core.py index 37ef9aa7..3182bda7 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -237,8 +237,19 @@ def test_jsonb_json(): "stream" in schema_message and schema_message["stream"] == altered_table_name ): - assert schema_message["schema"]["properties"]["column_jsonb"] == {} - assert schema_message["schema"]["properties"]["column_json"] == {} + all_types = { + "string", + "number", + "integer", + "object", + "array", + "boolean", + "null", + } + jsonb_schema = schema_message["schema"]["properties"]["column_jsonb"] + json_schema = schema_message["schema"]["properties"]["column_json"] + assert set(jsonb_schema["type"]) == all_types + assert set(json_schema["type"]) == all_types assert test_runner.records[altered_table_name][0] == { "column_jsonb": {"foo": "bar"}, "column_json": {"baz": "foo"},