Merge pull request #3558 from Budibase/fix/enrich-sql
Fixing SQL enrichment issue
This commit is contained in:
commit
415689c303
|
@ -1,4 +1,5 @@
|
||||||
import {
|
import {
|
||||||
|
FilterTypes,
|
||||||
IncludeRelationships,
|
IncludeRelationships,
|
||||||
Operation,
|
Operation,
|
||||||
PaginationJson,
|
PaginationJson,
|
||||||
|
@ -118,8 +119,13 @@ module External {
|
||||||
}
|
}
|
||||||
// check the row and filters to make sure they aren't a key of some sort
|
// check the row and filters to make sure they aren't a key of some sort
|
||||||
if (config.filters) {
|
if (config.filters) {
|
||||||
for (let filter of Object.values(config.filters)) {
|
for (let [key, filter] of Object.entries(config.filters)) {
|
||||||
if (typeof filter !== "object" || Object.keys(filter).length === 0) {
|
// oneOf is an array, don't iterate it
|
||||||
|
if (
|
||||||
|
typeof filter !== "object" ||
|
||||||
|
Object.keys(filter).length === 0 ||
|
||||||
|
key === FilterTypes.ONE_OF
|
||||||
|
) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
iterateObject(filter)
|
iterateObject(filter)
|
||||||
|
|
|
@ -54,6 +54,17 @@ export enum IncludeRelationships {
|
||||||
EXCLUDE = 0,
|
EXCLUDE = 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum FilterTypes {
|
||||||
|
STRING = "string",
|
||||||
|
FUZZY = "fuzzy",
|
||||||
|
RANGE = "range",
|
||||||
|
EQUAL = "equal",
|
||||||
|
NOT_EQUAL = "notEqual",
|
||||||
|
EMPTY = "empty",
|
||||||
|
NOT_EMPTY = "notEmpty",
|
||||||
|
ONE_OF = "oneOf",
|
||||||
|
}
|
||||||
|
|
||||||
export interface QueryDefinition {
|
export interface QueryDefinition {
|
||||||
type: QueryTypes
|
type: QueryTypes
|
||||||
displayName?: string
|
displayName?: string
|
||||||
|
|
|
@ -93,7 +93,7 @@ class InternalBuilder {
|
||||||
if (filters.oneOf) {
|
if (filters.oneOf) {
|
||||||
iterate(filters.oneOf, (key, array) => {
|
iterate(filters.oneOf, (key, array) => {
|
||||||
const fnc = allOr ? "orWhereIn" : "whereIn"
|
const fnc = allOr ? "orWhereIn" : "whereIn"
|
||||||
query = query[fnc](key, array)
|
query = query[fnc](key, Array.isArray(array) ? array : [array])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (filters.string) {
|
if (filters.string) {
|
||||||
|
|
Loading…
Reference in New Issue