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