Fix _some_ sqs problems.
This commit is contained in:
parent
f211990117
commit
bd17770e4e
|
@ -3268,7 +3268,7 @@ if (descriptions.length) {
|
||||||
formula: {
|
formula: {
|
||||||
name: "formula",
|
name: "formula",
|
||||||
type: FieldType.FORMULA,
|
type: FieldType.FORMULA,
|
||||||
formula: formula,
|
formula,
|
||||||
responseType: opts?.responseType,
|
responseType: opts?.responseType,
|
||||||
formulaType: opts?.formulaType || FormulaType.DYNAMIC,
|
formulaType: opts?.formulaType || FormulaType.DYNAMIC,
|
||||||
},
|
},
|
||||||
|
@ -3276,7 +3276,7 @@ if (descriptions.length) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should be able to search for rows containing formulas", async () => {
|
it.only("should be able to search for rows containing formulas", async () => {
|
||||||
const { rows } = await config.api.row.search(table._id!)
|
const { rows } = await config.api.row.search(table._id!)
|
||||||
expect(rows.length).toBe(1)
|
expect(rows.length).toBe(1)
|
||||||
expect(rows[0].links.length).toBe(1)
|
expect(rows[0].links.length).toBe(1)
|
||||||
|
@ -3333,7 +3333,7 @@ if (descriptions.length) {
|
||||||
})
|
})
|
||||||
|
|
||||||
isInternal &&
|
isInternal &&
|
||||||
it.only("should coerce a static handlebars formula", async () => {
|
it("should coerce a static handlebars formula", async () => {
|
||||||
await updateFormulaColumn(encodeJS("return 1"), {
|
await updateFormulaColumn(encodeJS("return 1"), {
|
||||||
responseType: FieldType.NUMBER,
|
responseType: FieldType.NUMBER,
|
||||||
formulaType: FormulaType.STATIC,
|
formulaType: FormulaType.STATIC,
|
||||||
|
|
|
@ -180,19 +180,6 @@ function cleanupFilters(filters: SearchFilters, allTables: Table[]) {
|
||||||
return filters
|
return filters
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildTableMap(tables: Table[]) {
|
|
||||||
const tableMap: Record<string, Table> = {}
|
|
||||||
for (let table of tables) {
|
|
||||||
// update the table name, should never query by name for SQLite
|
|
||||||
table.originalName = table.name
|
|
||||||
table.name = table._id!
|
|
||||||
// need a primary for sorting, lookups etc
|
|
||||||
table.primary = ["_id"]
|
|
||||||
tableMap[table._id!] = table
|
|
||||||
}
|
|
||||||
return tableMap
|
|
||||||
}
|
|
||||||
|
|
||||||
// table is only needed to handle relationships
|
// table is only needed to handle relationships
|
||||||
function reverseUserColumnMapping(rows: Row[], table?: Table) {
|
function reverseUserColumnMapping(rows: Row[], table?: Table) {
|
||||||
const prefixLength = USER_COLUMN_PREFIX.length
|
const prefixLength = USER_COLUMN_PREFIX.length
|
||||||
|
@ -315,7 +302,11 @@ export async function search(
|
||||||
}
|
}
|
||||||
|
|
||||||
const allTables = await sdk.tables.getAllInternalTables()
|
const allTables = await sdk.tables.getAllInternalTables()
|
||||||
const allTablesMap = buildTableMap(allTables)
|
const allTablesMap = allTables.reduce((acc, table) => {
|
||||||
|
acc[table._id!] = table
|
||||||
|
return acc
|
||||||
|
}, {} as Record<string, Table>)
|
||||||
|
|
||||||
// make sure we have the mapped/latest table
|
// make sure we have the mapped/latest table
|
||||||
if (table._id) {
|
if (table._id) {
|
||||||
table = allTablesMap[table._id]
|
table = allTablesMap[table._id]
|
||||||
|
|
|
@ -73,6 +73,17 @@ export function processRowCountResponse(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processInternalTables(tables: Table[]) {
|
||||||
|
const tableMap: Record<string, Table> = {}
|
||||||
|
for (let table of tables) {
|
||||||
|
// update the table name, should never query by name for SQLite
|
||||||
|
table.originalName = table.name
|
||||||
|
table.name = table._id!
|
||||||
|
tableMap[table._id!] = table
|
||||||
|
}
|
||||||
|
return tableMap
|
||||||
|
}
|
||||||
|
|
||||||
export async function enrichQueryJson(
|
export async function enrichQueryJson(
|
||||||
json: QueryJson
|
json: QueryJson
|
||||||
): Promise<EnrichedQueryJson> {
|
): Promise<EnrichedQueryJson> {
|
||||||
|
@ -85,10 +96,7 @@ export async function enrichQueryJson(
|
||||||
if (datasource) {
|
if (datasource) {
|
||||||
tables = datasource.entities || {}
|
tables = datasource.entities || {}
|
||||||
} else {
|
} else {
|
||||||
tables = {}
|
tables = processInternalTables(await sdk.tables.getAllInternalTables())
|
||||||
for (const table of await sdk.tables.getAllInternalTables()) {
|
|
||||||
tables[table._id!] = table
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const table = tables[json.endpoint.entityId]
|
const table = tables[json.endpoint.entityId]
|
||||||
|
|
|
@ -46,6 +46,7 @@ export async function processTable(table: Table): Promise<Table> {
|
||||||
const processed: Table = {
|
const processed: Table = {
|
||||||
...table,
|
...table,
|
||||||
type: "table",
|
type: "table",
|
||||||
|
primary: ["_id"], // internal tables must always use _id as primary key
|
||||||
sourceId: table.sourceId || INTERNAL_TABLE_SOURCE_ID,
|
sourceId: table.sourceId || INTERNAL_TABLE_SOURCE_ID,
|
||||||
sourceType: TableSourceType.INTERNAL,
|
sourceType: TableSourceType.INTERNAL,
|
||||||
sql: true,
|
sql: true,
|
||||||
|
|
Loading…
Reference in New Issue