chore: view inference (#3060)

This commit is contained in:
ChengLei Shao 2023-11-18 22:35:20 +08:00 committed by GitHub
parent 0acd7b6dd3
commit eac8559104
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -102,7 +102,14 @@ export class ViewFieldInference {
} }
if (!inferResult.type) { if (!inferResult.type) {
Object.assign(inferResult, this.inferToFieldType({ db, name, type: column.type })); Object.assign(
inferResult,
this.inferToFieldType({
dialect: db.sequelize.getDialect(),
name,
type: column.type,
}),
);
} }
rawFields.push([name, inferResult]); rawFields.push([name, inferResult]);
@ -111,9 +118,8 @@ export class ViewFieldInference {
return Object.fromEntries(rawFields); return Object.fromEntries(rawFields);
} }
static inferToFieldType(options: { db: Database; name: string; type: string }) { static inferToFieldType(options: { name: string; type: string; dialect: string }) {
const { db } = options; const { dialect } = options;
const dialect = db.sequelize.getDialect();
const fieldTypeMap = FieldTypeMap[dialect]; const fieldTypeMap = FieldTypeMap[dialect];
if (!options.type) { if (!options.type) {