Allowing incorrectly setup column schemas to still function as part of search - requires further investigation as to how this happens, but search should still work.
This commit is contained in:
parent
d03915d194
commit
9733ba5f95
|
@ -71,8 +71,7 @@ export function basicProcessing({
|
|||
}): Row {
|
||||
const thisRow: Row = {}
|
||||
// filter the row down to what is actually the row (not joined)
|
||||
for (let field of Object.values(table.schema)) {
|
||||
const fieldName = field.name
|
||||
for (let fieldName of Object.keys(table.schema)) {
|
||||
let value = extractFieldValue({
|
||||
row,
|
||||
tableName: table.name,
|
||||
|
|
|
@ -2353,6 +2353,35 @@ describe.each([
|
|||
})
|
||||
})
|
||||
|
||||
describe("Invalid column definitions", () => {
|
||||
beforeAll(async () => {
|
||||
// need to create an invalid table - means ignoring typescript
|
||||
table = await createTable({
|
||||
// @ts-ignore
|
||||
invalid: {
|
||||
type: FieldType.STRING,
|
||||
},
|
||||
name: {
|
||||
name: "name",
|
||||
type: FieldType.STRING,
|
||||
},
|
||||
})
|
||||
await createRows([
|
||||
{ name: "foo", invalid: "id1" },
|
||||
{ name: "bar", invalid: "id2" },
|
||||
])
|
||||
})
|
||||
|
||||
it("can get rows with all table data", async () => {
|
||||
await expectSearch({
|
||||
query: {},
|
||||
}).toContain([
|
||||
{ name: "foo", invalid: "id1" },
|
||||
{ name: "bar", invalid: "id2" },
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe.each(["data_name_test", "name_data_test", "name_test_data_"])(
|
||||
"special (%s) case",
|
||||
column => {
|
||||
|
|
|
@ -15,6 +15,7 @@ import { helpers, utils } from "@budibase/shared-core"
|
|||
import { pipeline } from "stream/promises"
|
||||
import tmp from "tmp"
|
||||
import fs from "fs"
|
||||
import { merge } from "lodash"
|
||||
|
||||
type PrimitiveTypes =
|
||||
| FieldType.STRING
|
||||
|
@ -291,10 +292,12 @@ function copyExistingPropsOver(
|
|||
const fetchedColumnDefinition: FieldSchema | undefined =
|
||||
table.schema[key]
|
||||
table.schema[key] = {
|
||||
...existingTableSchema[key],
|
||||
// merge the properties - anything missing will be filled in, old definition preferred
|
||||
...merge(fetchedColumnDefinition, existingTableSchema[key]),
|
||||
// always take externalType and autocolumn from the fetched definition
|
||||
externalType:
|
||||
existingTableSchema[key].externalType ||
|
||||
table.schema[key]?.externalType,
|
||||
fetchedColumnDefinition?.externalType,
|
||||
autocolumn: fetchedColumnDefinition?.autocolumn,
|
||||
} as FieldSchema
|
||||
// check constraints which can be fetched from the DB (they could be updated)
|
||||
|
|
|
@ -73,13 +73,14 @@ function buildInternalFieldList(
|
|||
fieldList = fieldList.concat(
|
||||
PROTECTED_INTERNAL_COLUMNS.map(col => `${table._id}.${col}`)
|
||||
)
|
||||
for (let col of Object.values(table.schema)) {
|
||||
for (let key of Object.keys(table.schema)) {
|
||||
const col = table.schema[key]
|
||||
const isRelationship = col.type === FieldType.LINK
|
||||
if (!opts?.relationships && isRelationship) {
|
||||
continue
|
||||
}
|
||||
if (!isRelationship) {
|
||||
fieldList.push(`${table._id}.${mapToUserColumn(col.name)}`)
|
||||
fieldList.push(`${table._id}.${mapToUserColumn(key)}`)
|
||||
} else {
|
||||
const linkCol = col as RelationshipFieldMetadata
|
||||
const relatedTable = tables.find(table => table._id === linkCol.tableId)
|
||||
|
|
Loading…
Reference in New Issue