Skip to content

Commit

Permalink
Preserve quotes round trip (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
robastel authored May 25, 2023
1 parent 1ede80d commit c749c72
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions dbt_invoke/internal/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def parse_yaml(location):
:return: The contents of the yaml file
"""
yaml = YAML(typ="rt")
yaml.preserve_quotes = True
with open(location, 'r') as stream:
try:
parsed_yaml = yaml.load(stream)
Expand All @@ -101,6 +102,7 @@ def write_yaml(location, data, mode='w'):
:return: None
"""
yaml = YAML(typ="rt")
yaml.preserve_quotes = True
try:
with open(location, mode) as stream:
yaml.dump(data, stream)
Expand Down
2 changes: 1 addition & 1 deletion dbt_invoke/internal/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2.2'
__version__ = '0.2.3'
7 changes: 7 additions & 0 deletions tests/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ def test_multiline_quotes(self):
expected_file="customers_multiline_quotes_expected.yml",
)

def test_preserve_quotes(self):
self.edit_update_compare(
"customers_preserve_quotes.yml",
target_model="customers",
expected_file="customers_preserve_quotes_expected.yml",
)

def test_long_string(self):
self.edit_update_compare(
"customers_long_string.yml",
Expand Down
11 changes: 11 additions & 0 deletions tests/test_property_files/customers_preserve_quotes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
models:
- name: customers
description: A description
config:
labels: {'contains_pii': 'no', 'created_by': 'somebody'}
columns:
- name: customer_id
description: ''
- name: created_at
description: ''
11 changes: 11 additions & 0 deletions tests/test_property_files/customers_preserve_quotes_expected.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
models:
- name: customers
description: A description
config:
labels: {'contains_pii': 'no', 'created_by': 'somebody'}
columns:
- name: customer_id
description: ''
- name: created_at
description: ''

0 comments on commit c749c72

Please sign in to comment.