From 0fc6b517ccc0da83dccc6e5acf5b7b22a2fd8e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Thu, 27 Jul 2023 12:33:44 -0600 Subject: [PATCH] fix: Expose `add_record_metadata` as a builtin target setting --- singer_sdk/helpers/capabilities.py | 7 +++++++ singer_sdk/target_base.py | 3 +++ tests/core/test_target_base.py | 1 + 3 files changed, 11 insertions(+) diff --git a/singer_sdk/helpers/capabilities.py b/singer_sdk/helpers/capabilities.py index 55aff8ce3..f5b5fa305 100644 --- a/singer_sdk/helpers/capabilities.py +++ b/singer_sdk/helpers/capabilities.py @@ -99,6 +99,13 @@ description="The default target database schema name to use for all streams.", ), ).to_dict() +ADD_RECORD_METADATA_CONFIG = PropertiesList( + Property( + "add_record_metadata", + BooleanType(), + description="Add metadata to records.", + ), +).to_dict() class DeprecatedEnum(Enum): diff --git a/singer_sdk/target_base.py b/singer_sdk/target_base.py index b5a2ad5e2..d08fe42e0 100644 --- a/singer_sdk/target_base.py +++ b/singer_sdk/target_base.py @@ -17,6 +17,7 @@ from singer_sdk.helpers._classproperty import classproperty from singer_sdk.helpers._compat import final from singer_sdk.helpers.capabilities import ( + ADD_RECORD_METADATA_CONFIG, BATCH_CONFIG, TARGET_SCHEMA_CONFIG, CapabilitiesEnum, @@ -594,6 +595,8 @@ def _merge_missing(source_jsonschema: dict, target_jsonschema: dict) -> None: if k not in target_jsonschema["properties"]: target_jsonschema["properties"][k] = v + _merge_missing(ADD_RECORD_METADATA_CONFIG, config_jsonschema) + capabilities = cls.capabilities if PluginCapabilities.BATCH in capabilities: diff --git a/tests/core/test_target_base.py b/tests/core/test_target_base.py index ed72b8496..68e413d6a 100644 --- a/tests/core/test_target_base.py +++ b/tests/core/test_target_base.py @@ -72,3 +72,4 @@ def test_target_about_info(): assert "flattening_enabled" in about.settings["properties"] assert "flattening_max_depth" in about.settings["properties"] assert "batch_config" in about.settings["properties"] + assert "add_record_metadata" in about.settings["properties"]