Skip to content

Commit

Permalink
Ignore adapter-level support for custom constraints (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtcohen6 authored Feb 19, 2024
1 parent ad0a548 commit 9d48e41
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240215-141545.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Ignore adapter-level support warnings for 'custom' constraints
time: 2024-02-15T14:15:45.764145+01:00
custom:
Author: jtcohen6
Issue: "90"
3 changes: 3 additions & 0 deletions dbt/adapters/base/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,9 @@ def process_parsed_constraint(
parsed_constraint: Union[ColumnLevelConstraint, ModelLevelConstraint],
render_func,
) -> Optional[str]:
# skip checking enforcement if this is a 'custom' constraint
if parsed_constraint.type == ConstraintType.custom:
return render_func(parsed_constraint)
if (
parsed_constraint.warn_unsupported
and cls.CONSTRAINT_SUPPORT[parsed_constraint.type] == ConstraintSupport.NOT_SUPPORTED
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_base_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def connection_manager(self):
["column_name integer references other_table (c1)"],
),
([{"type": "check"}, {"type": "unique"}], ["column_name integer unique"]),
([{"type": "custom", "expression": "-- noop"}], ["column_name integer -- noop"]),
]

@pytest.mark.parametrize("constraints,expected_rendered_constraints", column_constraints)
Expand Down

0 comments on commit 9d48e41

Please sign in to comment.