You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We perform unique and not null tests on all primary key columns. Previously, not_null data tests had to be specified repeatedly for the same columns that are also listed in the unique_combination_of_columns test.
Solution
The proposed solution adds an optional for loop that performs not null tests on each column in the unique_combination_of_columns test. Gives neater code. The default parameter is false, so it should not be a breaking change.
Describe the feature
A neat way to enforce primary keys is to have an option to not only use the "unique_combination_of_columns" test for unique tests of composite keys, but also for enforcing the not_null constraint for each of the underlying columns. This way developers have the option of not having to individually repeat single not_null tests for each of the columns listed in the "unique_combination_of_columns" test. This results in better readability, and hence better code quality.
Describe alternatives you've considered
Have considered writing a separate macro which combines these two types of tests, but I think it seemed more useful to have the not_null option inside the unique_combination_of_columns macro.
Additional context
Primary keys are not enforced on Snowflake, but unique_combination_of_columns and not_null can be used as a way around to enforce it.
Who will this benefit?
Enforcing primary keys in all databases.
Are you interested in contributing this feature?
Yes, already have a pull request ready (simple for loop).
The text was updated successfully, but these errors were encountered:
A major flaw with this suggestion as it is coded right now is that when the test fails, it does not say whether it is the unique combination or not_null part that fails.
Problem
We perform unique and not null tests on all primary key columns. Previously, not_null data tests had to be specified repeatedly for the same columns that are also listed in the unique_combination_of_columns test.
Solution
The proposed solution adds an optional for loop that performs not null tests on each column in the unique_combination_of_columns test. Gives neater code. The default parameter is false, so it should not be a breaking change.
Describe the feature
A neat way to enforce primary keys is to have an option to not only use the "unique_combination_of_columns" test for unique tests of composite keys, but also for enforcing the not_null constraint for each of the underlying columns. This way developers have the option of not having to individually repeat single not_null tests for each of the columns listed in the "unique_combination_of_columns" test. This results in better readability, and hence better code quality.
Describe alternatives you've considered
Have considered writing a separate macro which combines these two types of tests, but I think it seemed more useful to have the not_null option inside the unique_combination_of_columns macro.
Additional context
Primary keys are not enforced on Snowflake, but unique_combination_of_columns and not_null can be used as a way around to enforce it.
Who will this benefit?
Enforcing primary keys in all databases.
Are you interested in contributing this feature?
Yes, already have a pull request ready (simple for loop).
The text was updated successfully, but these errors were encountered: