Move constants to types

This commit is contained in:
Adria Navarro 2024-07-09 12:24:59 +02:00
parent 60dc6f2138
commit 9c6347f7fd
3 changed files with 9 additions and 7 deletions

View File

@ -15,6 +15,7 @@ import {
FieldSchema,
FieldType,
INTERNAL_TABLE_SOURCE_ID,
InternalSearchFilterOperator,
JsonFieldMetadata,
JsonTypes,
Operation,
@ -170,8 +171,6 @@ function convertBooleans(query: SqlQuery | SqlQuery[]): SqlQuery | SqlQuery[] {
return query
}
const COMPLEX_ID_OPERATOR = "_complexIdOperator"
class InternalBuilder {
private readonly client: string
@ -215,7 +214,7 @@ class InternalBuilder {
const updatedKey = dbCore.removeKeyNumbering(key)
const isRelationshipField = updatedKey.includes(".")
if (updatedKey === COMPLEX_ID_OPERATOR) {
if (updatedKey === InternalSearchFilterOperator.COMPLEX_ID_OPERATOR) {
const alias = getTableAlias(tableName)
fn(
value.id.map((x: string) => (alias ? `${alias}.${x}` : x)),
@ -753,8 +752,6 @@ class InternalBuilder {
class SqlQueryBuilder extends SqlTableQueryBuilder {
private readonly limit: number
public static COMPLEX_ID_OPERATOR = COMPLEX_ID_OPERATOR
// pass through client to get flavour of SQL
constructor(client: string, limit: number = BASE_LIMIT) {
super(client)

View File

@ -7,6 +7,7 @@ import {
FieldType,
FilterType,
IncludeRelationship,
InternalSearchFilterOperator,
isManyToOne,
OneToManyRelationshipFieldMetadata,
Operation,
@ -40,7 +41,7 @@ import {
} from "../../../sdk/app/rows/utils"
import { processObjectSync } from "@budibase/string-templates"
import { cloneDeep } from "lodash/fp"
import { db as dbCore, sql } from "@budibase/backend-core"
import { db as dbCore } from "@budibase/backend-core"
import sdk from "../../../sdk"
import env from "../../../environment"
import { makeExternalQuery } from "../../../integrations/base/query"
@ -195,7 +196,7 @@ export class ExternalRequest<T extends Operation> {
if (primary) {
const parts = breakRowIdField(operator[field])
if (primary.length > 1) {
operator[sql.Sql.COMPLEX_ID_OPERATOR] = {
operator[InternalSearchFilterOperator.COMPLEX_ID_OPERATOR] = {
id: primary,
values: parts[0],
}

View File

@ -17,6 +17,10 @@ export enum SearchFilterOperator {
CONTAINS_ANY = "containsAny",
}
export enum InternalSearchFilterOperator {
COMPLEX_ID_OPERATOR = "_complexIdOperator",
}
export interface SearchFilters {
allOr?: boolean
// TODO: this is just around for now - we need a better way to do or/and