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

feat(nulltest): add not_null option to unique_combination_of_columns.sql #964

Closed
wants to merge 2 commits into from

Conversation

halfos
Copy link

@halfos halfos commented Nov 13, 2024

Add option to enforce uniqueness and non-null constraints on composite primary key columns in one test.

This introduces an option to ensure that composite primary key columns are both unique and do not contain null values. This is beneficial as it reduces the need for duplicate tests by allowing these constraints to be specified directly in a single test.

resolves #963

Problem

I 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.

One problem can be that putting them together in one test may make it difficult to see which part of the test failed.

Checklist

  • This code is associated with an issue which has been triaged and accepted for development.
  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the README.md (if applicable)

halfos and others added 2 commits November 13, 2024 09:57
Add option to enforce uniqueness and non-null constraints on composite primary key columns in one test.

This introduces an option to ensure that composite primary key columns are both unique and do not contain null values. This is beneficial as it reduces the need for duplicate tests by allowing these constraints to be specified directly in a single test.
@halfos
Copy link
Author

halfos commented Nov 13, 2024

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.

@halfos halfos closed this Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(nulltest): add not_null option to unique_combination_of_columns
1 participant