1
0
Fork 0
mirror of synced 2024-10-04 20:13:35 +13:00

Merge pull request #14687 from Budibase/chore/search-tests-from-views

Search tests from views
This commit is contained in:
Adria Navarro 2024-10-03 11:10:34 +02:00 committed by GitHub
commit 2a99e6a0ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 2778 additions and 2731 deletions

View file

@ -124,9 +124,11 @@ export async function buildSqlFieldList(
([columnName, column]) => ([columnName, column]) =>
column.type !== FieldType.LINK && column.type !== FieldType.LINK &&
column.type !== FieldType.FORMULA && column.type !== FieldType.FORMULA &&
!existing.find((field: string) => field === columnName) !existing.find(
(field: string) => field === `${table.name}.${columnName}`
)
) )
.map(column => `${table.name}.${column[0]}`) .map(([columnName]) => `${table.name}.${columnName}`)
} }
let fields: string[] = [] let fields: string[] = []

File diff suppressed because it is too large Load diff

View file

@ -22,9 +22,9 @@ import {
RelationshipType, RelationshipType,
TableSchema, TableSchema,
RenameColumn, RenameColumn,
ViewFieldMetadata,
FeatureFlag, FeatureFlag,
BBReferenceFieldSubType, BBReferenceFieldSubType,
ViewV2Schema,
ViewCalculationFieldMetadata, ViewCalculationFieldMetadata,
} from "@budibase/types" } from "@budibase/types"
import { generator, mocks } from "@budibase/backend-core/tests" import { generator, mocks } from "@budibase/backend-core/tests"
@ -1180,10 +1180,7 @@ describe.each([
return table return table
} }
const createView = async ( const createView = async (tableId: string, schema: ViewV2Schema) =>
tableId: string,
schema: Record<string, ViewFieldMetadata>
) =>
await config.api.viewV2.create({ await config.api.viewV2.create({
name: generator.guid(), name: generator.guid(),
tableId, tableId,

View file

@ -23,8 +23,8 @@ import {
Row, Row,
Table, Table,
TableSchema, TableSchema,
ViewFieldMetadata,
ViewV2, ViewV2,
ViewV2Schema,
} from "@budibase/types" } from "@budibase/types"
import sdk from "../../sdk" import sdk from "../../sdk"
import { helpers } from "@budibase/shared-core" import { helpers } from "@budibase/shared-core"
@ -262,7 +262,7 @@ export async function squashLinks<T = Row[] | Row>(
FeatureFlag.ENRICHED_RELATIONSHIPS FeatureFlag.ENRICHED_RELATIONSHIPS
) )
let viewSchema: Record<string, ViewFieldMetadata> = {} let viewSchema: ViewV2Schema = {}
if (sdk.views.isView(source)) { if (sdk.views.isView(source)) {
if (helpers.views.isCalculationView(source)) { if (helpers.views.isCalculationView(source)) {
return enriched return enriched

View file

@ -93,6 +93,8 @@ export async function search(
// Lucene does not accept conditional filters, so we need to keep the old logic // Lucene does not accept conditional filters, so we need to keep the old logic
const query: SearchFilters = viewQuery const query: SearchFilters = viewQuery
delete options.query.onEmptyFilter
// Extract existing fields // Extract existing fields
const existingFields = const existingFields =
view.query view.query
@ -115,6 +117,9 @@ export async function search(
conditions: [viewQuery, options.query], conditions: [viewQuery, options.query],
}, },
} }
if (viewQuery.onEmptyFilter) {
options.query.onEmptyFilter = viewQuery.onEmptyFilter
}
} }
} }

View file

@ -7,11 +7,11 @@ import {
BulkImportRequest, BulkImportRequest,
BulkImportResponse, BulkImportResponse,
SearchRowResponse, SearchRowResponse,
RowSearchParams,
DeleteRows, DeleteRows,
DeleteRow, DeleteRow,
PaginatedSearchRowResponse, PaginatedSearchRowResponse,
RowExportFormat, RowExportFormat,
SearchRowRequest,
} from "@budibase/types" } from "@budibase/types"
import { Expectations, TestAPI } from "./base" import { Expectations, TestAPI } from "./base"
@ -136,7 +136,7 @@ export class RowAPI extends TestAPI {
) )
} }
search = async <T extends RowSearchParams>( search = async <T extends SearchRowRequest>(
sourceId: string, sourceId: string,
params?: T, params?: T,
expectations?: Expectations expectations?: Expectations

View file

@ -71,9 +71,11 @@ export interface ViewV2 {
order?: SortOrder order?: SortOrder
type?: SortType type?: SortType
} }
schema?: Record<string, ViewFieldMetadata> schema?: ViewV2Schema
} }
export type ViewV2Schema = Record<string, ViewFieldMetadata>
export type ViewSchema = ViewCountOrSumSchema | ViewStatisticsSchema export type ViewSchema = ViewCountOrSumSchema | ViewStatisticsSchema
export interface ViewCountOrSumSchema { export interface ViewCountOrSumSchema {