Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore adapter-level support for custom constraints #91

Merged
merged 4 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
mikealfare marked this conversation as resolved.
Show resolved Hide resolved
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
Loading