数组字段类型推断

This commit is contained in:
2020-05-20 21:01:56 +08:00
parent edff19c434
commit 66a52e8405

View File

@@ -19,6 +19,14 @@ export enum DataType {
string = 'string', string = 'string',
} }
const TypeCompatibility = {
string: 5,
float: 4,
int: 3,
bool: 2,
null: 1
};
export interface ColumnDescription { export interface ColumnDescription {
type: DataType; type: DataType;
name: string; name: string;
@@ -165,6 +173,9 @@ export class TableParser {
let field = field_maps.get(column.name); let field = field_maps.get(column.name);
field.column.is_array = true; field.column.is_array = true;
field.indexes.push(c_idx); field.indexes.push(c_idx);
if (TypeCompatibility[column.type] > TypeCompatibility[field.column.type]) {
field.column.type = column.type;
}
} }
c_idx += 1; c_idx += 1;
} }