Skip to content

Commit

Permalink
[Backport 1.7.latest] Fix the semicolon semantics for indexes while r…
Browse files Browse the repository at this point in the history
…especting other bug fix (#10194)

* backport postgres#97
* point to the correct reference for run_dbt

---------

Co-authored-by: Gerda Shank <[email protected]>
  • Loading branch information
mikealfare and gshank authored May 21, 2024
1 parent d0ddeea commit 879ae14
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240514-193201.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix the semicolon semantics for indexes while respecting other bug fix
time: 2024-05-14T19:32:01.149383-07:00
custom:
Author: versusfacit
Issue: "85"
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@

{%- if _index_change.action == "drop" -%}

{{ postgres__get_drop_index_sql(relation, _index.name) }};
{{ postgres__get_drop_index_sql(relation, _index.name) }}

{%- elif _index_change.action == "create" -%}

{{ postgres__get_create_index_sql(relation, _index.as_node_config) }}

{%- endif -%}
{{ ';' if not loop.last else "" }}

{%- endfor -%}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
create materialized view if not exists {{ relation }} as {{ sql }};

{% for _index_dict in config.get('indexes', []) -%}
{{- get_create_index_sql(relation, _index_dict) -}}
{{- get_create_index_sql(relation, _index_dict) -}}{{ ';' if not loop.last else "" }}
{%- endfor -%}

{% endmacro %}
27 changes: 27 additions & 0 deletions tests/functional/postgres/test_multiple_indexes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pytest

from dbt.tests.util import run_dbt


REF_MULTIPLE_INDEX_MODEL = """
{{
config(
materialized="materialized_view",
indexes=[
{"columns": ["foo"], "type": "btree"},
{"columns": ["bar"], "type": "btree"},
],
)
}}
SELECT 1 AS foo, 2 AS bar
"""


class TestUnrestrictedPackageAccess:
@pytest.fixture(scope="class")
def models(self):
return {"index_test.sql": REF_MULTIPLE_INDEX_MODEL}

def test_unrestricted_protected_ref(self, project):
run_dbt()

0 comments on commit 879ae14

Please sign in to comment.