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

add tests for rendering foreign key and unique constraints #596

Merged
merged 8 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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/Under the Hood-20230511-144429.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: test foreign key + unique constraint rendering
time: 2023-05-11T14:44:29.374015-04:00
custom:
Author: michelleark
Issue: "7417"
4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# install latest changes in dbt-core
# TODO: how to automate switching from develop to version branches?
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter
git+https://github.com/dbt-labs/dbt-core.git@fix-constraint-rendering#egg=dbt-core&subdirectory=core
git+https://github.com/dbt-labs/dbt-core.git@fix-constraint-rendering#egg=dbt-tests-adapter&subdirectory=tests/adapter

# if version 1.x or greater -> pin to major version
# if version 0.x -> pin to minor
Expand Down
9 changes: 6 additions & 3 deletions tests/functional/adapter/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@

_expected_sql_snowflake = """
create or replace transient table <model_identifier> (
id integer not null primary key,
id integer not null primary key references <foreign_key_model_identifier> (id) unique,
color text,
date_day text
) as ( select
id,
color,
date_day from
(
-- depends_on: <foreign_key_model_identifier>
select
'blue' as color,
1 as id,
Expand Down Expand Up @@ -113,15 +114,17 @@ def expected_sql(self):
color text,
date_day text,
primary key (id),
constraint strange_uniqueness_requirement unique (color, date_day)
constraint strange_uniqueness_requirement unique (color, date_day),
foreign key (id) references <foreign_key_model_identifier> (id)
) as ( select
id,
color,
date_day from
(
-- depends_on: <foreign_key_model_identifier>
select
1 as id,
'blue' as color,
1 as id,
'2019-01-01' as date_day
) as model_subq
);
Expand Down