This repository has been archived by the owner on Sep 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AP-659] Fix extracting data from tables with space in the name (#49)
- Loading branch information
Showing
2 changed files
with
82 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import unittest | ||
|
||
from tap_postgres.sync_strategies import logical_replication | ||
|
||
|
||
class TestLogicalReplication(unittest.TestCase): | ||
maxDiff = None | ||
|
||
def setUp(self): | ||
pass | ||
|
||
def test_streams_to_wal2json_tables(self): | ||
"""Validate if table names are escaped to wal2json format""" | ||
streams = [ | ||
{'metadata': [{'metadata': {'schema-name': 'public'}}], | ||
'table_name': 'dummy_table'}, | ||
{'metadata': [{'metadata': {'schema-name': 'public'}}], | ||
'table_name': 'CaseSensitiveTable'}, | ||
{'metadata': [{'metadata': {'schema-name': 'public'}}], | ||
'table_name': 'Case Sensitive Table With Space'}, | ||
{'metadata': [{'metadata': {'schema-name': 'CaseSensitiveSchema'}}], | ||
'table_name': 'dummy_table'}, | ||
{'metadata': [{'metadata': {'schema-name': 'Case Sensitive Schema With Space'}}], | ||
'table_name': 'CaseSensitiveTable'}, | ||
{'metadata': [{'metadata': {'schema-name': 'Case Sensitive Schema With Space'}}], | ||
'table_name': 'Case Sensitive Table With Space'}, | ||
{'metadata': [{'metadata': {'schema-name': 'public'}}], | ||
'table_name': 'table_with_comma_,'}, | ||
{'metadata': [{'metadata': {'schema-name': 'public'}}], | ||
'table_name': "table_with_quote_'"} | ||
] | ||
|
||
self.assertEqual(logical_replication.streams_to_wal2json_tables(streams), | ||
'public.dummy_table,' | ||
'public.CaseSensitiveTable,' | ||
'public.Case\\ Sensitive\\ Table\\ With\\ Space,' | ||
'CaseSensitiveSchema.dummy_table,' | ||
'Case\\ Sensitive\\ Schema\\ With\\ Space.CaseSensitiveTable,' | ||
'Case\\ Sensitive\\ Schema\\ With\\ Space.Case\\ Sensitive\\ Table\\ With\\ Space,' | ||
'public.table_with_comma_\\,,' | ||
"public.table_with_quote_\\'") |