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

Forbid default value nullification for non-nullable field #6258

Merged
merged 3 commits into from
Jul 15, 2024

Conversation

ijreilly
Copy link
Collaborator

@ijreilly ijreilly commented Jul 15, 2024

as per title

Enregistrement.de.l.ecran.2024-07-15.a.12.07.45.mov

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

  • Added validation to prevent nullification of default values for non-nullable fields (packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.service.ts)
  • Introduced utility function assertDoesNotNullifyDefaultValueForNonNullableField (packages/twenty-server/src/engine/metadata-modules/field-metadata/utils/assert-does-not-nullify-default-value-for-non-nullable-field.util.ts)
  • Integrated new utility function into updateOne method (packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.service.ts)
  • Added but did not utilize private method nullifiesDefaultValueForNonNullableField (packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.service.ts)

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

(updates since last review)

  • Removed nullifiesDefaultValueForNonNullableField method (packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.service.ts)
  • Integrated assertDoesNotNullifyDefaultValueForNonNullableField utility function for validation
  • Ensured non-nullable fields' default values cannot be set to null during updates

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

FieldMetadataExceptionCode,
} from 'src/engine/metadata-modules/field-metadata/field-metadata.exception';

export const assertDoesNotNullifyDefaultValueForNonNullableField = ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a unit test on this util?

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

(updates since last review)

  • Added unit tests in packages/twenty-server/src/engine/metadata-modules/field-metadata/utils/__tests__/assert-does-not-nullify-default-value-for-non-nullable-field.spec.ts
  • Modified validation logic in packages/twenty-server/src/engine/metadata-modules/field-metadata/utils/assert-does-not-nullify-default-value-for-non-nullable-field.util.ts to enforce non-nullable field constraints

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@ijreilly ijreilly merged commit aed0bf4 into main Jul 15, 2024
6 checks passed
@ijreilly ijreilly deleted the forbid-remove-default-value-if-non-nullable branch July 15, 2024 12:22
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.

2 participants