Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve quotes round trip #33

Merged
merged 1 commit into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: ''