Type checks pass.

This commit is contained in:
Sam Rose 2024-11-26 17:09:32 +00:00
parent c35e443225
commit 8e756ccf84
No known key found for this signature in database
2 changed files with 6 additions and 15 deletions

View File

@ -7,6 +7,7 @@ import {
Table, Table,
TableSourceType, TableSourceType,
SqlClient, SqlClient,
EnrichedQueryJson,
} from "@budibase/types" } from "@budibase/types"
import { sql } from "@budibase/backend-core" import { sql } from "@budibase/backend-core"
import { join } from "path" import { join } from "path"
@ -35,8 +36,8 @@ describe("Captures of real examples", () => {
const relationshipLimit = 500 const relationshipLimit = 500
const primaryLimit = 100 const primaryLimit = 100
function getJson(name: string): QueryJson { function getJson(name: string) {
return require(join(__dirname, "sqlQueryJson", name)) as QueryJson return require(join(__dirname, "sqlQueryJson", name)) as EnrichedQueryJson
} }
describe("create", () => { describe("create", () => {
@ -252,9 +253,6 @@ describe("Captures of real examples", () => {
resource: { resource: {
fields, fields,
}, },
meta: {
table: TABLE,
},
} }
} }

View File

@ -241,19 +241,12 @@ export async function save(
} }
const operation = tableId ? Operation.UPDATE_TABLE : Operation.CREATE_TABLE const operation = tableId ? Operation.UPDATE_TABLE : Operation.CREATE_TABLE
await makeTableRequest( await makeTableRequest(datasource, operation, tableToSave, opts?.renaming)
datasource,
operation,
tableToSave,
tables,
oldTable,
opts?.renaming
)
// update any extra tables (like foreign keys in other tables) // update any extra tables (like foreign keys in other tables)
for (let extraTable of extraTablesToUpdate) { for (let extraTable of extraTablesToUpdate) {
const oldExtraTable = oldTables[extraTable.name] const oldExtraTable = oldTables[extraTable.name]
let op = oldExtraTable ? Operation.UPDATE_TABLE : Operation.CREATE_TABLE let op = oldExtraTable ? Operation.UPDATE_TABLE : Operation.CREATE_TABLE
await makeTableRequest(datasource, op, extraTable, tables, oldExtraTable) await makeTableRequest(datasource, op, extraTable)
} }
// make sure the constrained list, all still exist // make sure the constrained list, all still exist
@ -292,7 +285,7 @@ export async function destroy(datasourceId: string, table: Table) {
const operation = Operation.DELETE_TABLE const operation = Operation.DELETE_TABLE
if (tables) { if (tables) {
await makeTableRequest(datasource, operation, table, tables) await makeTableRequest(datasource, operation, table)
cleanupRelationships(table, tables, { deleting: true }) cleanupRelationships(table, tables, { deleting: true })
delete tables[table.name] delete tables[table.name]
datasource.entities = tables datasource.entities = tables