-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Conversation
There was a problem hiding this 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
There was a problem hiding this 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 = ({ |
There was a problem hiding this comment.
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?
There was a problem hiding this 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
as per title
Enregistrement.de.l.ecran.2024-07-15.a.12.07.45.mov