Browse Source

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.

pull/4023/head
mike12345567 5 years ago
parent
commit
d06ab10c1d
  1. 10
      packages/server/src/api/controllers/row/ExternalRequest.ts
  2. 11
      packages/server/src/definitions/datasource.ts
  3. 2
      packages/server/src/integrations/base/sql.ts

10
packages/server/src/api/controllers/row/ExternalRequest.ts

@ -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)

11
packages/server/src/definitions/datasource.ts

@ -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

2
packages/server/src/integrations/base/sql.ts

@ -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) {

Loading…
Cancel
Save