First test passes!

This commit is contained in:
Sam Rose 2023-10-19 09:47:50 +01:00
parent 6517150f32
commit 77729737bc
No known key found for this signature in database
5 changed files with 19 additions and 10 deletions

View File

@ -1,4 +1,4 @@
import { IncludeRelationship, Operation, Row } from "@budibase/types"
import { IncludeRelationship, Operation } from "@budibase/types"
import { handleRequest } from "../../../api/controllers/row/external"
import { breakRowIdField } from "../../../integrations/utils"

View File

@ -1,4 +1,4 @@
import { SearchFilters, SearchParams } from "@budibase/types"
import { Row, SearchFilters, SearchParams } from "@budibase/types"
import { isExternalTable } from "../../../integrations/utils"
import * as internal from "./search/internal"
import * as external from "./search/external"
@ -45,10 +45,14 @@ export async function exportRows(
return pickApi(options.tableId).exportRows(options)
}
export async function fetch(tableId: string) {
export async function fetch(tableId: string): Promise<Row[]> {
return pickApi(tableId).fetch(tableId)
}
export async function fetchRaw(tableId: string): Promise<Row[]> {
return pickApi(tableId).fetchRaw(tableId)
}
export async function fetchView(
tableId: string,
viewName: string,

View File

@ -186,6 +186,12 @@ export async function fetch(tableId: string): Promise<Row[]> {
})
}
export async function fetchRaw(tableId: string): Promise<Row[]> {
return await handleRequest<Operation.READ>(Operation.READ, tableId, {
includeSqlRelationships: IncludeRelationship.INCLUDE,
})
}
export async function fetchView(viewName: string) {
// there are no views in external datasources, shouldn't ever be called
// for now just fetch

View File

@ -140,14 +140,13 @@ export async function exportRows(
}
export async function fetch(tableId: string): Promise<Row[]> {
const db = context.getAppDB()
const table = await sdk.tables.getTable(tableId)
const rows = await getRawTableData(db, tableId)
const rows = await fetchRaw(tableId)
return await outputProcessing(table, rows)
}
async function getRawTableData(db: Database, tableId: string) {
export async function fetchRaw(tableId: string): Promise<Row[]> {
const db = context.getAppDB()
let rows
if (tableId === InternalTables.USER_METADATA) {
rows = await sdk.users.fetchMetadata()
@ -182,7 +181,7 @@ export async function fetchView(
})
} else {
const tableId = viewInfo.meta.tableId
const data = await getRawTableData(db, tableId)
const data = await fetchRaw(tableId)
response = await inMemoryViews.runView(
viewInfo,
calculation as string,

View File

@ -28,7 +28,7 @@ export async function migrate(
await migrator.doMigration()
delete table.schema[oldColumn.name]
await sdk.tables.saveTable(table)
table = await sdk.tables.saveTable(table)
await updateLinks({ eventType: EventType.TABLE_UPDATED, table, oldTable })
}
@ -88,7 +88,7 @@ class UserColumnMigrator implements ColumnMigrator {
) {}
async doMigration() {
let rows = await sdk.rows.fetch(this.table._id!)
let rows = await sdk.rows.fetchRaw(this.table._id!)
let rowsById = rows.reduce((acc, row) => {
acc[row._id!] = row
return acc