Skip to content

Commit

Permalink
Add test to restore transactions behavior. (#24)
Browse files Browse the repository at this point in the history
Co-authored-by: Mila Page <[email protected]>
Co-authored-by: Mike Alfare <[email protected]>
Co-authored-by: Mike Alfare <[email protected]>
  • Loading branch information
4 people authored Mar 21, 2024
1 parent 618c85d commit 23880f4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240226-225642.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Add unit test for transaction semantics.
time: 2024-02-26T22:56:42.202429-08:00
custom:
Author: versusfacit
Issue: "23"
10 changes: 5 additions & 5 deletions dbt/adapters/postgres/relation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import FrozenSet, Optional, Set

from dbt.adapters.base.relation import BaseRelation
Expand All @@ -20,19 +20,19 @@

@dataclass(frozen=True, eq=False, repr=False)
class PostgresRelation(BaseRelation):
renameable_relations = frozenset(
renameable_relations: FrozenSet[RelationType] = field(default_factory=lambda: frozenset(
{
RelationType.View,
RelationType.Table,
RelationType.MaterializedView,
}
)
replaceable_relations = frozenset(
))
replaceable_relations: FrozenSet[RelationType] = field(default_factory=lambda: frozenset(
{
RelationType.View,
RelationType.Table,
}
)
))

def __post_init__(self):
# Check for length of Postgres table/view names.
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/test_renamed_relations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from dbt.adapters.postgres.relation import PostgresRelation
from dbt.adapters.contracts.relation import RelationType


def test_renameable_relation():
relation = PostgresRelation.create(
database="my_db",
schema="my_schema",
identifier="my_table",
type=RelationType.Table,
)
assert relation.renameable_relations == frozenset({
RelationType.View,
RelationType.Table,
RelationType.MaterializedView,
})

0 comments on commit 23880f4

Please sign in to comment.