修正结构体 null 检查

This commit is contained in:
2021-01-26 16:13:07 +08:00
parent 14c8a3b910
commit a799681194

View File

@@ -164,10 +164,10 @@ export class Field {
let obj = {}; let obj = {};
let isAllNullish = true; let isAllNullish = true;
for (const c of this.children) { for (const c of this.children) {
let value = c.parse_row(row); let value = c.check_is_null(row) ? null : c.parse_row(row);
if (c.is_array) { if (c.is_array) {
let arr: any[] = obj[c.name] || []; let arr: any[] = obj[c.name] || [];
if (this.constant_array_length || value != null) { if (this.constant_array_length || value) {
arr.push(value); arr.push(value);
} }
obj[c.name] = arr; obj[c.name] = arr;
@@ -194,6 +194,22 @@ export class Field {
return null; return null;
} }
} }
protected check_is_null(row: RawTableCell[]): boolean {
if (this.children) {
let isAllNullish = true;
for (const c of this.children) {
isAllNullish = isAllNullish && c.check_is_null(row);
if (!isAllNullish) {
return false;
}
}
return isAllNullish;
} else {
let cell = row[this.columns.start];
return !cell || cell.t === 'z';
}
}
} }
const TypeCompatibility = { const TypeCompatibility = {