Merge pull request #14687 from Budibase/chore/search-tests-from-views
Search tests from views
This commit is contained in:
commit
2a99e6a0ee
|
@ -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
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue