Respond to PR feedback.
This commit is contained in:
parent
ae281c3e7a
commit
32bd505ef9
1 changed files with 15 additions and 7 deletions
|
@ -12,6 +12,14 @@ import { dataFilters } from "@budibase/shared-core"
|
|||
|
||||
export const removeKeyNumbering = dataFilters.removeKeyNumbering
|
||||
|
||||
function isEmpty(value: any) {
|
||||
return (
|
||||
value == null ||
|
||||
value === "" ||
|
||||
(Array.isArray(value) && value.length === 0)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to build lucene query URLs.
|
||||
* Optionally takes a base lucene query object.
|
||||
|
@ -282,14 +290,14 @@ export class QueryBuilder<T> {
|
|||
}
|
||||
|
||||
const equal = (key: string, value: any) => {
|
||||
if (value === null || value === undefined) {
|
||||
if (isEmpty(value)) {
|
||||
return null
|
||||
}
|
||||
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`
|
||||
}
|
||||
|
||||
const contains = (key: string, value: any, mode = "AND") => {
|
||||
if (!value || (Array.isArray(value) && value.length === 0)) {
|
||||
if (isEmpty(value)) {
|
||||
return null
|
||||
}
|
||||
if (!Array.isArray(value)) {
|
||||
|
@ -305,7 +313,7 @@ export class QueryBuilder<T> {
|
|||
}
|
||||
|
||||
const fuzzy = (key: string, value: any) => {
|
||||
if (!value) {
|
||||
if (isEmpty(value)) {
|
||||
return null
|
||||
}
|
||||
value = builder.preprocess(value, {
|
||||
|
@ -327,7 +335,7 @@ export class QueryBuilder<T> {
|
|||
}
|
||||
|
||||
const oneOf = (key: string, value: any) => {
|
||||
if (!value) {
|
||||
if (isEmpty(value)) {
|
||||
return `*:*`
|
||||
}
|
||||
if (!Array.isArray(value)) {
|
||||
|
@ -385,7 +393,7 @@ export class QueryBuilder<T> {
|
|||
// Construct the actual lucene search query string from JSON structure
|
||||
if (this.#query.string) {
|
||||
build(this.#query.string, (key: string, value: any) => {
|
||||
if (!value) {
|
||||
if (isEmpty(value)) {
|
||||
return null
|
||||
}
|
||||
value = builder.preprocess(value, {
|
||||
|
@ -398,7 +406,7 @@ export class QueryBuilder<T> {
|
|||
}
|
||||
if (this.#query.range) {
|
||||
build(this.#query.range, (key: string, value: any) => {
|
||||
if (!value) {
|
||||
if (isEmpty(value)) {
|
||||
return null
|
||||
}
|
||||
if (value.low == null || value.low === "") {
|
||||
|
@ -420,7 +428,7 @@ export class QueryBuilder<T> {
|
|||
}
|
||||
if (this.#query.notEqual) {
|
||||
build(this.#query.notEqual, (key: string, value: any) => {
|
||||
if (value === null || value === undefined) {
|
||||
if (isEmpty(value)) {
|
||||
return null
|
||||
}
|
||||
if (typeof value === "boolean") {
|
||||
|
|
Loading…
Reference in a new issue