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

Escape upstream descriptions in generate_model_yaml #159

Merged
merged 5 commits into from
Feb 28, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Fixes
- Column `description` fields are now correctly escaped in `generate_model_yaml` ([#142](https://github.com/dbt-labs/dbt-codegen/issues/142))

# dbt-codegen v0.11.0

## 🚨 Breaking change
Expand Down
4 changes: 2 additions & 2 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'codegen'
version: '0.5.0'
name: "codegen"
version: "0.5.0"

require-dbt-version: [">=1.1.0", "<2.0.0"]
config-version: 2
Expand Down
16 changes: 10 additions & 6 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: 'codegen_integration_tests'
version: '1.0'
name: "codegen_integration_tests"
version: "1.0"
config-version: 2

profile: 'integration_tests'
profile: "integration_tests"

model-paths: ["models"]
analysis-paths: ["analyses"]
Expand All @@ -12,12 +12,16 @@ macro-paths: ["macros"]

target-path: "target"
clean-targets:
- "target"
- "dbt_packages"
- "target"
- "dbt_packages"

seeds:
+schema: raw_data
+quote_columns: false

vars:
my_table_reference: table_c
my_table_reference: table_c

models:
+bind: false

4 changes: 2 additions & 2 deletions integration_tests/macros/operations/create_source_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ reset enable_case_sensitive_identifier;
{% do adapter.create_schema(target_schema) %}

{% set drop_table_sql %}
drop table if exists {{ target_schema }}.codegen_integration_tests__data_source_table
drop table if exists {{ target_schema }}.codegen_integration_tests__data_source_table {% if target.type == "redshift" %}cascade{% endif %}
{% endset %}

{{ run_query(drop_table_sql) }}
Expand All @@ -33,7 +33,7 @@ create table {{ target_schema }}.codegen_integration_tests__data_source_table as
{{ run_query(create_table_sql) }}

{% set drop_table_sql_case_sensitive %}
drop table if exists {{ target_schema }}.codegen_integration_tests__data_source_table_case_sensitive
drop table if exists {{ target_schema }}.codegen_integration_tests__data_source_table_case_sensitive {% if target.type == "redshift" %}cascade{% endif %}
{% endset %}

{{ run_query(drop_table_sql_case_sensitive) }}
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/models/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ models:
- name: model_data_a
columns:
- name: col_a
description: description column a
description: 'description column "a"'
5 changes: 5 additions & 0 deletions integration_tests/package-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
packages:
- local: ../
- package: dbt-labs/dbt_utils
version: 1.1.1
sha1_hash: de2deba3d66ce03d8c02949013650cc9b94f6030
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ models:
description: ""
columns:
- name: col_a
description: "description column a"
description: "description column \"a\""

- name: col_b
description: ""
Expand Down
2 changes: 1 addition & 1 deletion macros/generate_model_yaml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{% if include_data_types %}
{% do model_yaml.append(' data_type: ' ~ codegen.data_type_format_model(column)) %}
{% endif %}
{% do model_yaml.append(' description: "' ~ column_desc_dict.get(column.name | lower,'') ~ '"') %}
{% do model_yaml.append(' description: ' ~ (column_desc_dict.get(column.name | lower,'') | tojson)) %}
{% do model_yaml.append('') %}

{% if column.fields|length > 0 %}
Expand Down