Skip to content

Commit

Permalink
Allow empty key_properties and replication keys in standard metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
dmosorast committed Aug 28, 2019
1 parent 9b99c6e commit 0720f5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions singer/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
8 changes: 8 additions & 0 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': []}}])

0 comments on commit 0720f5c

Please sign in to comment.