diff --git a/singer/metadata.py b/singer/metadata.py index dd2b85c..41153ea 100644 --- a/singer/metadata.py +++ b/singer/metadata.py @@ -26,11 +26,11 @@ def get_standard_metadata(schema=None, schema_name=None, key_properties=None, valid_replication_keys=None, replication_method=None): mdata = {} - if key_properties: + if key_properties is not None: mdata = write(mdata, (), 'table-key-properties', key_properties) if replication_method: mdata = write(mdata, (), 'forced-replication-method', replication_method) - if valid_replication_keys: + if valid_replication_keys is not None: mdata = write(mdata, (), 'valid-replication-keys', valid_replication_keys) if schema: mdata = write(mdata, (), 'inclusion', 'available') diff --git a/tests/test_metadata.py b/tests/test_metadata.py index 8fa271d..fd97ef2 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -325,3 +325,11 @@ def test_standard_metadata(self): for obj in expected_metadata: if obj in test_value: self.assertIn(obj, test_value) + + def test_empty_key_properties_are_written(self): + mdata = get_standard_metadata(key_properties=[]) + self.assertEqual(mdata, [{'breadcrumb': (), 'metadata': {'table-key-properties': []}}]) + + def test_empty_valid_replication_keys_are_written(self): + mdata = get_standard_metadata(valid_replication_keys=[]) + self.assertEqual(mdata, [{'breadcrumb': (), 'metadata': {'valid-replication-keys': []}}])