Skip to content

Commit

Permalink
add tests for rendering foreign key and unique constraints (#596)
Browse files Browse the repository at this point in the history
(cherry picked from commit efe2eba)
  • Loading branch information
MichelleArk committed Jun 8, 2023
1 parent 3c08070 commit f4df481
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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"
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

0 comments on commit f4df481

Please sign in to comment.