Some sqs fixes.

This commit is contained in:
Sam Rose 2024-11-26 17:36:17 +00:00
parent 8e756ccf84
commit f211990117
No known key found for this signature in database
4 changed files with 14 additions and 6 deletions

View File

@ -3,6 +3,7 @@ import * as dbCore from "../db"
import { import {
getNativeSql, getNativeSql,
isExternalTable, isExternalTable,
isInternalTableID,
isInvalidISODateString, isInvalidISODateString,
isValidFilter, isValidFilter,
isValidISODateString, isValidISODateString,
@ -1192,7 +1193,7 @@ class InternalBuilder {
private buildJsonField(table: Table, field: string): [string, Knex.Raw] { private buildJsonField(table: Table, field: string): [string, Knex.Raw] {
const parts = field.split(".") const parts = field.split(".")
const baseName = parts[parts.length - 1] let baseName = parts[parts.length - 1]
let unaliased: string let unaliased: string
let tableField: string let tableField: string
@ -1205,10 +1206,16 @@ class InternalBuilder {
tableField = unaliased tableField = unaliased
} }
const schema = table.schema[baseName] if (this.query.meta?.columnPrefix) {
baseName = baseName.replace(this.query.meta.columnPrefix, "")
}
let identifier = this.rawQuotedIdentifier(tableField) let identifier = this.rawQuotedIdentifier(tableField)
if (schema.type === FieldType.BIGINT) { // Internal tables have special _id, _rev, createdAt, and updatedAt fields
// that do not appear in the schema, meaning schema could actually be
// undefined.
const schema: FieldSchema | undefined = table.schema[baseName]
if (schema && schema.type === FieldType.BIGINT) {
identifier = this.castIntToString(identifier) identifier = this.castIntToString(identifier)
} }
return [unaliased, identifier] return [unaliased, identifier]

View File

@ -29,7 +29,7 @@ import sdk from "../../sdk"
import { builderSocket } from "../../websockets" import { builderSocket } from "../../websockets"
import { isEqual } from "lodash" import { isEqual } from "lodash"
import { processTable } from "../../sdk/app/tables/getters" import { processTable } from "../../sdk/app/tables/getters"
import { makeExternalQuery } from "src/integrations/base/query" import { makeExternalQuery } from "../../integrations/base/query"
export async function fetch(ctx: UserCtx) { export async function fetch(ctx: UserCtx) {
ctx.body = await sdk.datasources.fetch() ctx.body = await sdk.datasources.fetch()

View File

@ -3333,7 +3333,7 @@ if (descriptions.length) {
}) })
isInternal && isInternal &&
it("should coerce a static handlebars formula", async () => { it.only("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,

View File

@ -494,6 +494,7 @@ export async function search(
if (err.status === 400 && msg?.match(MISSING_COLUMN_REGEX)) { if (err.status === 400 && msg?.match(MISSING_COLUMN_REGEX)) {
return { rows: [] } return { rows: [] }
} }
throw new Error(`Unable to search by SQL - ${msg}`, { cause: err }) // throw new Error(`Unable to search by SQL - ${msg}`, { cause: err })
throw err
} }
} }