Fixing issue found with enriching rows in SQL - the system was assuming the array of entries contained a row ID that needed to be broken down.

This commit is contained in:
mike12345567 2021-11-26 17:08:56 +00:00
parent 531985c8da
commit d06ab10c1d
3 changed files with 20 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import {
FilterTypes,
IncludeRelationships,
Operation,
PaginationJson,
@ -118,8 +119,13 @@ module External {
}
// check the row and filters to make sure they aren't a key of some sort
if (config.filters) {
for (let filter of Object.values(config.filters)) {
if (typeof filter !== "object" || Object.keys(filter).length === 0) {
for (let [key, filter] of Object.entries(config.filters)) {
// oneOf is an array, don't iterate it
if (
typeof filter !== "object" ||
Object.keys(filter).length === 0 ||
key === FilterTypes.ONE_OF
) {
continue
}
iterateObject(filter)

View File

@ -54,6 +54,17 @@ export enum IncludeRelationships {
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 {
type: QueryTypes
displayName?: string

View File

@ -93,7 +93,7 @@ class InternalBuilder {
if (filters.oneOf) {
iterate(filters.oneOf, (key, array) => {
const fnc = allOr ? "orWhereIn" : "whereIn"
query = query[fnc](key, array)
query = query[fnc](key, Array.isArray(array) ? array : [array])
})
}
if (filters.string) {