File tree Expand file tree Collapse file tree
dbt/include/sqlserver/macros/relations/table
tests/functional/adapter/mssql Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333 EXEC(' {{- escape_single_quotes(query) -}}' )
3434
3535 {# For some reason drop_relation is not firing. This solves the issue for now. #}
36- EXEC(' DROP VIEW IF EXISTS {{tmp_relation.schema}}.{{tmp_relation.identifier }}' )
36+ EXEC(' DROP VIEW IF EXISTS {{ tmp_relation.include(database=False) }}' )
3737
3838
3939
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ from dbt .tests .util import run_dbt
4+
5+ model_sql = """
6+ {{ config(materialized="table") }}
7+ select 1 as id
8+ """
9+
10+
11+ class TestReservedKeywordsSchema :
12+ @pytest .fixture (scope = "class" )
13+ def models (self ):
14+ return {"model.sql" : model_sql }
15+
16+ @pytest .fixture (scope = "class" )
17+ def project_config_update (self ):
18+ return {
19+ "name" : "test_reserved_keywords_schema" ,
20+ "quoting" : {
21+ "database" : True ,
22+ "schema" : True ,
23+ "identifier" : True ,
24+ },
25+ "models" : {
26+ "test_reserved_keywords_schema" : {
27+ "schema" : "group" ,
28+ }
29+ },
30+ }
31+
32+ @pytest .fixture (scope = "class" )
33+ def macros (self ):
34+ return {
35+ "generate_schema_name.sql" : """
36+ {% macro generate_schema_name(custom_schema_name, node) -%}
37+ {%- if custom_schema_name -%}
38+ {{ custom_schema_name | trim }}
39+ {%- else -%}
40+ {{ target.schema }}
41+ {%- endif -%}
42+ {%- endmacro %}
43+ """
44+ }
45+
46+ @pytest .fixture (autouse = True , scope = "class" )
47+ def cleanup_schema (self , project ):
48+ yield
49+ project .run_sql ("DROP TABLE IF EXISTS [group].[model]" )
50+ project .run_sql ("DROP SCHEMA IF EXISTS [group]" )
51+
52+ def test_reserved_schema (self , project ):
53+ results = run_dbt (["run" ])
54+ assert len (results ) == 1
55+ assert results [0 ].status == "success"
You can’t perform that action at this time.
0 commit comments