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]) =>
column.type !== FieldType.LINK &&
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[] = []

File diff suppressed because it is too large Load diff

View file

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

View file

@ -23,8 +23,8 @@ import {
Row,
Table,
TableSchema,
ViewFieldMetadata,
ViewV2,
ViewV2Schema,
} from "@budibase/types"
import sdk from "../../sdk"
import { helpers } from "@budibase/shared-core"
@ -262,7 +262,7 @@ export async function squashLinks<T = Row[] | Row>(
FeatureFlag.ENRICHED_RELATIONSHIPS
)
let viewSchema: Record<string, ViewFieldMetadata> = {}
let viewSchema: ViewV2Schema = {}
if (sdk.views.isView(source)) {
if (helpers.views.isCalculationView(source)) {
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
const query: SearchFilters = viewQuery
delete options.query.onEmptyFilter
// Extract existing fields
const existingFields =
view.query
@ -115,6 +117,9 @@ export async function search(
conditions: [viewQuery, options.query],
},
}
if (viewQuery.onEmptyFilter) {
options.query.onEmptyFilter = viewQuery.onEmptyFilter
}
}
}

View file

@ -7,11 +7,11 @@ import {
BulkImportRequest,
BulkImportResponse,
SearchRowResponse,
RowSearchParams,
DeleteRows,
DeleteRow,
PaginatedSearchRowResponse,
RowExportFormat,
SearchRowRequest,
} from "@budibase/types"
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,
params?: T,
expectations?: Expectations

View file

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