fix(drizzle, ui): properly filters out number field values with the exists operator filter (#8706)

Filtering by `null` `number` field values or normal values with the
`exists` operator was not working in `postgres` & `sqlite`.

Was previously fixed for `mongodb`
[here](https://github.com/payloadcms/payload/pull/8416)

Now fixed for `postgres` & `sqlite` adapters as well.
This commit is contained in:
Patrik
2024-10-14 19:23:22 -04:00
committed by GitHub
parent a9e7d4884e
commit 3f2b828298
2 changed files with 7 additions and 4 deletions

View File

@@ -223,8 +223,11 @@ export const sanitizeQueryValue = ({
}
if (operator === 'exists') {
formattedValue = formattedValue === 'true' || formattedValue === true
if (formattedValue === false) {
formattedValue = val === 'true' || val === true
if (formattedValue) {
operator = 'exists'
} else {
operator = 'isNull'
}
}

View File

@@ -133,13 +133,13 @@ export const DefaultCell: React.FC<CellComponentProps> = (props) => {
} else {
return (
<WrapElement {...wrapElementProps}>
{(cellData === '' || typeof cellData === 'undefined') &&
{(cellData === '' || typeof cellData === 'undefined' || cellData === null) &&
i18n.t('general:noLabel', {
label: getTranslation(('label' in field ? field.label : null) || 'data', i18n),
})}
{typeof cellData === 'string' && cellData}
{typeof cellData === 'number' && cellData}
{typeof cellData === 'object' && JSON.stringify(cellData)}
{typeof cellData === 'object' && cellData !== null && JSON.stringify(cellData)}
</WrapElement>
)
}