fix: fix nested references?
This commit is contained in:
parent
97c8b1966c
commit
d5fdb69ad7
|
|
@ -395,12 +395,24 @@ export function parseCsv(
|
||||||
return config;
|
return config;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Collect all referenced tables
|
// Collect all referenced tables (including nested references in tuples/arrays)
|
||||||
const references = new Set<string>();
|
const references = new Set<string>();
|
||||||
|
function collectReferences(schema: Schema): void {
|
||||||
|
if (schema.type === 'reference') {
|
||||||
|
references.add(schema.tableName);
|
||||||
|
} else if (schema.type === 'tuple') {
|
||||||
|
schema.elements.forEach(el => collectReferences(el.schema));
|
||||||
|
} else if (schema.type === 'array') {
|
||||||
|
collectReferences(schema.element);
|
||||||
|
} else if (schema.type === 'union') {
|
||||||
|
schema.members.forEach(m => collectReferences(m));
|
||||||
|
}
|
||||||
|
}
|
||||||
propertyConfigs.forEach(config => {
|
propertyConfigs.forEach(config => {
|
||||||
if (config.isReference && config.referenceTableName) {
|
if (config.isReference && config.referenceTableName) {
|
||||||
references.add(config.referenceTableName);
|
references.add(config.referenceTableName);
|
||||||
}
|
}
|
||||||
|
collectReferences(config.schema);
|
||||||
});
|
});
|
||||||
|
|
||||||
const dataRows = records.slice(2);
|
const dataRows = records.slice(2);
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,8 @@ class Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (identifier.length === 0) {
|
if (identifier.length === 0) {
|
||||||
throw new ParseError('Expected schema or named schema', this.pos);
|
const schema = this.parseSchema();
|
||||||
|
return { schema };
|
||||||
}
|
}
|
||||||
|
|
||||||
this.skipWhitespace();
|
this.skipWhitespace();
|
||||||
|
|
|
||||||
|
|
@ -265,6 +265,10 @@ class ValueParser {
|
||||||
let hasOpenBracket = false;
|
let hasOpenBracket = false;
|
||||||
const elementIsTupleOrArray = schema.element.type === 'tuple' || schema.element.type === 'array';
|
const elementIsTupleOrArray = schema.element.type === 'tuple' || schema.element.type === 'array';
|
||||||
|
|
||||||
|
if (this.pos >= this.input.length || !this.input.trim()) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
if (this.peek() === '[') {
|
if (this.peek() === '[') {
|
||||||
if (!elementIsTupleOrArray) {
|
if (!elementIsTupleOrArray) {
|
||||||
this.consume();
|
this.consume();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue