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') { if (operator === 'exists') {
formattedValue = formattedValue === 'true' || formattedValue === true formattedValue = val === 'true' || val === true
if (formattedValue === false) {
if (formattedValue) {
operator = 'exists'
} else {
operator = 'isNull' operator = 'isNull'
} }
} }

View File

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