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

Add test for source names with quotes #10588

Merged
merged 1 commit into from
Aug 21, 2024
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
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240821-095516.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Add test for sources tables with quotes
time: 2024-08-21T09:55:16.038101-04:00
custom:
Author: gshank
Issue: "10582"
31 changes: 31 additions & 0 deletions tests/functional/sources/test_name_chars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from dbt.tests.util import get_manifest, run_dbt, write_file
from tests.fixtures.jaffle_shop import JaffleShopProject

# Note: in an actual file (as opposed to a string that we write into a files)
# there would only be a single backslash.
sources_yml = """
sources:
- name: something_else
database: raw
schema: jaffle_shop
tables:
- name: "\\"/test/orders\\""
- name: customers
"""


class TestNameChars(JaffleShopProject):
def test_quotes_in_table_names(self, project):
# Write out a sources definition that includes a table name with quotes and a forward slash
# Note: forward slashes are not legal in filenames in Linux (or Windows),
# so we won't see forward slashes in model names, because they come from file names.
write_file(sources_yml, project.project_root, "models", "sources.yml")
manifest = run_dbt(["parse"])
assert len(manifest.sources) == 2
assert 'source.jaffle_shop.something_else."/test/orders"' in manifest.sources.keys()
# We've written out the manifest.json artifact, we want to ensure
# that it can be read in again (the json is valid).
# Note: the key in the json actually looks like: "source.jaffle_shop.something_else.\"/test/orders\""
new_manifest = get_manifest(project.project_root)
assert new_manifest
assert 'source.jaffle_shop.something_else."/test/orders"' in new_manifest.sources.keys()
Loading