Enable support for handling shallow non-object arrays in JSON fields
This commit is contained in:
parent
20ee863780
commit
a5b4087f64
|
@ -7,6 +7,10 @@ export const convertJSONSchemaToTableSchema = (
|
|||
}
|
||||
if (jsonSchema.schema) {
|
||||
jsonSchema = jsonSchema.schema
|
||||
} else {
|
||||
jsonSchema = {
|
||||
value: jsonSchema,
|
||||
}
|
||||
}
|
||||
const keys = extractJSONSchemaKeys(jsonSchema, squashObjects)
|
||||
let schema = {}
|
||||
|
|
|
@ -194,18 +194,18 @@
|
|||
// For providers referencing another provider, just use the rows it
|
||||
// provides
|
||||
allRows = dataSource?.value?.rows || []
|
||||
} else if (dataSource?.type === "field") {
|
||||
// Field sources will be available from context.
|
||||
// Enrich non object elements into object to ensure a valid schema.
|
||||
} else if (
|
||||
dataSource?.type === "field" ||
|
||||
dataSource?.type === "jsonarray"
|
||||
) {
|
||||
// These sources will be available directly from context.
|
||||
// Enrich non object elements into objects to ensure a valid schema.
|
||||
const data = dataSource?.value || []
|
||||
if (Array.isArray(data) && data[0] && typeof data[0] !== "object") {
|
||||
allRows = data.map(value => ({ value }))
|
||||
} else {
|
||||
allRows = data
|
||||
}
|
||||
} else if (dataSource?.type === "jsonarray") {
|
||||
// JSON array sources will be available from context
|
||||
allRows = dataSource?.value || []
|
||||
} else {
|
||||
// For other data sources like queries or views, fetch all rows from the
|
||||
// server
|
||||
|
|
Loading…
Reference in New Issue