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 {
|
}): Row {
|
||||||
const thisRow: Row = {}
|
const thisRow: Row = {}
|
||||||
// filter the row down to what is actually the row (not joined)
|
// filter the row down to what is actually the row (not joined)
|
||||||
for (let field of Object.values(table.schema)) {
|
for (let fieldName of Object.keys(table.schema)) {
|
||||||
const fieldName = field.name
|
|
||||||
let value = extractFieldValue({
|
let value = extractFieldValue({
|
||||||
row,
|
row,
|
||||||
tableName: table.name,
|
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_"])(
|
describe.each(["data_name_test", "name_data_test", "name_test_data_"])(
|
||||||
"special (%s) case",
|
"special (%s) case",
|
||||||
column => {
|
column => {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { helpers, utils } from "@budibase/shared-core"
|
||||||
import { pipeline } from "stream/promises"
|
import { pipeline } from "stream/promises"
|
||||||
import tmp from "tmp"
|
import tmp from "tmp"
|
||||||
import fs from "fs"
|
import fs from "fs"
|
||||||
|
import { merge } from "lodash"
|
||||||
|
|
||||||
type PrimitiveTypes =
|
type PrimitiveTypes =
|
||||||
| FieldType.STRING
|
| FieldType.STRING
|
||||||
|
@ -291,10 +292,12 @@ function copyExistingPropsOver(
|
||||||
const fetchedColumnDefinition: FieldSchema | undefined =
|
const fetchedColumnDefinition: FieldSchema | undefined =
|
||||||
table.schema[key]
|
table.schema[key]
|
||||||
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:
|
externalType:
|
||||||
existingTableSchema[key].externalType ||
|
existingTableSchema[key].externalType ||
|
||||||
table.schema[key]?.externalType,
|
fetchedColumnDefinition?.externalType,
|
||||||
autocolumn: fetchedColumnDefinition?.autocolumn,
|
autocolumn: fetchedColumnDefinition?.autocolumn,
|
||||||
} as FieldSchema
|
} as FieldSchema
|
||||||
// check constraints which can be fetched from the DB (they could be updated)
|
// check constraints which can be fetched from the DB (they could be updated)
|
||||||
|
|
|
@ -73,13 +73,14 @@ function buildInternalFieldList(
|
||||||
fieldList = fieldList.concat(
|
fieldList = fieldList.concat(
|
||||||
PROTECTED_INTERNAL_COLUMNS.map(col => `${table._id}.${col}`)
|
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
|
const isRelationship = col.type === FieldType.LINK
|
||||||
if (!opts?.relationships && isRelationship) {
|
if (!opts?.relationships && isRelationship) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (!isRelationship) {
|
if (!isRelationship) {
|
||||||
fieldList.push(`${table._id}.${mapToUserColumn(col.name)}`)
|
fieldList.push(`${table._id}.${mapToUserColumn(key)}`)
|
||||||
} else {
|
} else {
|
||||||
const linkCol = col as RelationshipFieldMetadata
|
const linkCol = col as RelationshipFieldMetadata
|
||||||
const relatedTable = tables.find(table => table._id === linkCol.tableId)
|
const relatedTable = tables.find(table => table._id === linkCol.tableId)
|
||||||
|
|
Loading…
Reference in New Issue