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

View File

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

View File

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