11312 rest api cant filter enum type columns by null value (#11343)

- Fixes https://github.com/twentyhq/twenty/issues/11312
- Fixes record undefined on webhook deleted events
- Emit destroy event when deleting record via the rest api
This commit is contained in:
martmull
2025-04-02 15:07:53 +02:00
committed by GitHub
parent 76bbffc315
commit 55eadf1ab4
5 changed files with 29 additions and 5 deletions

View File

@ -56,4 +56,24 @@ describe('checkFilterEnumValues', () => {
`'filter' enum value 'MISSING_OPTION' not available in '${fieldSelectMock.name}' enum. Available enum values are ['OPTION_1', 'OPTION_2']`,
);
});
it('should allow filter by NULL or NOT_NULL values', () => {
expect(() =>
checkFilterEnumValues(
FieldMetadataType.SELECT,
fieldSelectMock.name,
'NULL',
mockObjectMetadataWithFieldMaps,
),
).not.toThrow();
expect(() =>
checkFilterEnumValues(
FieldMetadataType.SELECT,
fieldSelectMock.name,
'NOT_NULL',
mockObjectMetadataWithFieldMaps,
),
).not.toThrow();
});
});

View File

@ -28,8 +28,10 @@ export const checkFilterEnumValues = (
if (!enumValues) {
return;
}
const allowedEnumValues = ['NULL', 'NOT_NULL', ...enumValues];
values.forEach((val) => {
if (!enumValues.includes(val)) {
if (!allowedEnumValues.includes(val)) {
throw new BadRequestException(
`'filter' enum value '${val}' not available in '${fieldName}' enum. Available enum values are ['${enumValues.join(
"', '",

View File

@ -35,7 +35,7 @@ export class RestApiCoreServiceV2 {
await repository.delete(recordId);
this.apiEventEmitterService.emitDeletedEvents(
this.apiEventEmitterService.emitDestroyEvents(
[recordToDelete],
this.getAuthContextFromRequest(request),
objectMetadata.objectMetadataMapItem,