From cd693968b974a532b3a00eb8ff006150c67d26d7 Mon Sep 17 00:00:00 2001 From: Aaron Barnaby Date: Tue, 17 Mar 2026 21:40:53 +0000 Subject: [PATCH] feat: add is_null support in filter --- src/utils/formatQueryString.js | 39 +++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/src/utils/formatQueryString.js b/src/utils/formatQueryString.js index 9fa7c44..a9da503 100644 --- a/src/utils/formatQueryString.js +++ b/src/utils/formatQueryString.js @@ -1,20 +1,29 @@ function formatFilterString(type, filter) { - const filterStringArray = Object.keys(filter).map(key => { - const value = filter[key] - let queryString = `${key},${value}` - - if (Array.isArray(value)) { - queryString = `${key},${value.join(',')}` - } else if (typeof value === 'object' && value !== null) { - queryString = Object.keys(value) - .map(attr => `${key}.${attr},${value[attr]}`) - .join(':') - } - return `${type}(${queryString})` - }) - - return filterStringArray.join(':') + // Handle is_null filter usage { is_null: field } or { is_null: [field1, field2] } + if (type === 'is_null') { + if (Array.isArray(filter)) { + return filter.map(item => `${type}(${item})`).join(':') + } + + return `${type}(${filter})` } + + const filterStringArray = Object.keys(filter).map(key => { + const value = filter[key] + let queryString = `${key},${value}` + + if (Array.isArray(value)) { + queryString = `${key},${value.join(',')}` + } else if (typeof value === 'object' && value !== null) { + queryString = Object.keys(value) + .map(attr => `${key}.${attr},${value[attr]}`) + .join(':') + } + return `${type}(${queryString})` + }) + + return filterStringArray.join(':') +}