Skip to content

Commit 4f91b6b

Browse files
fix: Add additionalProperties to fields of type object (#601)
1 parent 4fe1951 commit 4f91b6b

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

tap_postgres/client.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ def array_to_jsonschema(self, column_type: postgresql.ARRAY) -> dict:
6969
def json_to_jsonschema(self, column_type: postgresql.JSON) -> dict:
7070
"""Override the default mapping for JSON and JSONB columns."""
7171
if self.json_as_object:
72-
return {"type": ["object", "null"]}
73-
return {"type": ["string", "number", "integer", "array", "object", "boolean"]}
72+
return {
73+
"type": ["object", "null"],
74+
"additionalProperties": True,
75+
}
76+
return {
77+
"type": ["string", "number", "integer", "array", "object", "boolean"],
78+
"additionalProperties": True,
79+
}
7480

7581
@to_jsonschema.register
7682
def datetime_to_jsonschema(self, column_type: sqlalchemy.types.DateTime) -> dict:

tests/test_core.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ def test_jsonb_json():
258258
"object",
259259
"boolean",
260260
"null",
261-
]
261+
],
262+
"additionalProperties": True,
262263
}
263264
assert schema_message["schema"]["properties"]["column_json"] == {
264265
"type": [
@@ -269,7 +270,8 @@ def test_jsonb_json():
269270
"object",
270271
"boolean",
271272
"null",
272-
]
273+
],
274+
"additionalProperties": True,
273275
}
274276
for i in range(len(rows)):
275277
assert test_runner.records[altered_table_name][i] == rows[i]
@@ -330,7 +332,8 @@ def test_jsonb_array():
330332
"array",
331333
"object",
332334
"boolean",
333-
]
335+
],
336+
"additionalProperties": True,
334337
},
335338
"type": ["array", "null"],
336339
}
@@ -397,13 +400,15 @@ def test_json_as_object():
397400
"type": [
398401
"object",
399402
"null",
400-
]
403+
],
404+
"additionalProperties": True,
401405
}
402406
assert schema_message["schema"]["properties"]["column_json"] == {
403407
"type": [
404408
"object",
405409
"null",
406-
]
410+
],
411+
"additionalProperties": True,
407412
}
408413

409414
assert len(rows) == len(test_runner.records[altered_table_name])

0 commit comments

Comments
 (0)