From eac855910431b01ee1de89bffa85716f5a9e47ef Mon Sep 17 00:00:00 2001 From: ChengLei Shao Date: Sat, 18 Nov 2023 22:35:20 +0800 Subject: [PATCH] chore: view inference (#3060) --- packages/core/database/src/view/view-inference.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/core/database/src/view/view-inference.ts b/packages/core/database/src/view/view-inference.ts index 71deffd59..73f1b94b0 100644 --- a/packages/core/database/src/view/view-inference.ts +++ b/packages/core/database/src/view/view-inference.ts @@ -102,7 +102,14 @@ export class ViewFieldInference { } 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]); @@ -111,9 +118,8 @@ export class ViewFieldInference { return Object.fromEntries(rawFields); } - static inferToFieldType(options: { db: Database; name: string; type: string }) { - const { db } = options; - const dialect = db.sequelize.getDialect(); + static inferToFieldType(options: { name: string; type: string; dialect: string }) { + const { dialect } = options; const fieldTypeMap = FieldTypeMap[dialect]; if (!options.type) {