From 68522a87db92e0a620d54fe126e61d090ffd428a Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 2 Aug 2024 18:49:05 +0000 Subject: [PATCH] refactor: convert alias to string and remove knew.raw wrapper --- packages/nocodb/src/db/BaseModelSqlv2.ts | 17 +++-------------- .../nocodb/src/services/meta-diffs.service.ts | 10 ++++++++-- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index 9e7e751244..978c49d3d1 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -1011,10 +1011,7 @@ class BaseModelSqlv2 { ) .from(count.as(getAlias())); selectors.push( - this.dbDriver.raw(`(??) as "??"`, [ - subQuery, - this.dbDriver.raw(f.alias), - ]), + this.dbDriver.raw(`(??) as ??`, [subQuery, `${f.alias}`]), ); break; case 'mysql2': @@ -1391,10 +1388,7 @@ class BaseModelSqlv2 { ) .from(tQb.as(getAlias())); selectors.push( - this.dbDriver.raw(`(??) as "??"`, [ - subQuery, - this.dbDriver.raw(f.alias), - ]), + this.dbDriver.raw(`(??) as ??`, [subQuery, `${f.alias}`]), ); break; case 'mysql2': @@ -1597,12 +1591,7 @@ class BaseModelSqlv2 { tQb.select(jsonBuildObject); - selectors.push( - this.dbDriver.raw(`(??) as ??`, [ - tQb, - this.dbDriver.raw(`"${f.alias}"`), - ]), - ); + selectors.push(this.dbDriver.raw(`(??) as ??`, [tQb, `${f.alias}`])); } qb.select(...selectors); diff --git a/packages/nocodb/src/services/meta-diffs.service.ts b/packages/nocodb/src/services/meta-diffs.service.ts index ffeb6e892c..68145e8b06 100644 --- a/packages/nocodb/src/services/meta-diffs.service.ts +++ b/packages/nocodb/src/services/meta-diffs.service.ts @@ -448,7 +448,10 @@ export class MetaDiffsService { } for (const relation of relationList) { - if (!relation?.found?.[RelationTypes.BELONGS_TO] && !relation?.found?.[RelationTypes.ONE_TO_ONE]) { + if ( + !relation?.found?.[RelationTypes.BELONGS_TO] && + !relation?.found?.[RelationTypes.ONE_TO_ONE] + ) { changes .find((t) => t.table_name === relation.tn) ?.detectedChanges.push({ @@ -462,7 +465,10 @@ export class MetaDiffsService { cstn: relation.cstn, }); } - if (!relation?.found?.[RelationTypes.HAS_MANY] && !relation?.found?.[RelationTypes.ONE_TO_ONE]) { + if ( + !relation?.found?.[RelationTypes.HAS_MANY] && + !relation?.found?.[RelationTypes.ONE_TO_ONE] + ) { changes .find((t) => t.table_name === relation.rtn) ?.detectedChanges.push({