Checking the correct operation - also typeguarding the check.
This commit is contained in:
parent
a9acc7f87b
commit
3e1a0a60b4
|
@ -70,7 +70,12 @@ function generateSchema(
|
|||
case FieldType.LONGFORM:
|
||||
case FieldType.BARCODEQR:
|
||||
case FieldType.BB_REFERENCE_SINGLE:
|
||||
// primary key strings have to have a length in some DBs
|
||||
if (primaryKeys.includes(key)) {
|
||||
schema.string(key, 255)
|
||||
} else {
|
||||
schema.text(key)
|
||||
}
|
||||
break
|
||||
case FieldType.NUMBER:
|
||||
// if meta is specified then this is a junction table entry
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import dayjs from "dayjs"
|
||||
import {
|
||||
ArrayOperator,
|
||||
AutoFieldSubType,
|
||||
AutoReason,
|
||||
Datasource,
|
||||
|
@ -196,13 +195,13 @@ export class ExternalRequest<T extends Operation> {
|
|||
if (filters) {
|
||||
// need to map over the filters and make sure the _id field isn't present
|
||||
let prefix = 1
|
||||
for (const operator of Object.values(filters)) {
|
||||
const isArrayOperator = Object.values(ArrayOperator).includes(operator)
|
||||
for (const [operatorType, operator] of Object.entries(filters)) {
|
||||
const isArrayOp = sdk.rows.utils.isArrayFilter(operatorType)
|
||||
for (const field of Object.keys(operator || {})) {
|
||||
if (dbCore.removeKeyNumbering(field) === "_id") {
|
||||
if (primary) {
|
||||
const parts = breakRowIdField(operator[field])
|
||||
if (primary.length > 1 && isArrayOperator) {
|
||||
if (primary.length > 1 && isArrayOp) {
|
||||
operator[InternalSearchFilterOperator.COMPLEX_ID_OPERATOR] = {
|
||||
id: primary,
|
||||
values: parts[0],
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
Table,
|
||||
TableSchema,
|
||||
SqlClient,
|
||||
ArrayOperator,
|
||||
} from "@budibase/types"
|
||||
import { makeExternalQuery } from "../../../integrations/base/query"
|
||||
import { Format } from "../../../api/controllers/view/exporters"
|
||||
|
@ -311,3 +312,8 @@ function validateTimeOnlyField(
|
|||
|
||||
return res
|
||||
}
|
||||
|
||||
// type-guard check
|
||||
export function isArrayFilter(operator: any): operator is ArrayOperator {
|
||||
return Object.values(ArrayOperator).includes(operator)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue