Skip to content

Commit

Permalink
Fix the semicolon semantics for indexes while respecting other bug fi…
Browse files Browse the repository at this point in the history
…x. (#97)

Co-authored-by: Mila Page <[email protected]>
(cherry picked from commit e23d0a7)
  • Loading branch information
VersusFacit authored and mikealfare committed May 21, 2024
1 parent a6461e4 commit 8d08281
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/test_multiple_indexes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pytest

from tests.functional.utils 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 8d08281

Please sign in to comment.