Browse Source

refactor: convert alias to string and remove knew.raw wrapper

pull/9142/head
Pranav C 4 months ago
parent
commit
68522a87db
  1. 17
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 10
      packages/nocodb/src/services/meta-diffs.service.ts

17
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -1011,10 +1011,7 @@ class BaseModelSqlv2 {
) )
.from(count.as(getAlias())); .from(count.as(getAlias()));
selectors.push( selectors.push(
this.dbDriver.raw(`(??) as "??"`, [ this.dbDriver.raw(`(??) as ??`, [subQuery, `${f.alias}`]),
subQuery,
this.dbDriver.raw(f.alias),
]),
); );
break; break;
case 'mysql2': case 'mysql2':
@ -1391,10 +1388,7 @@ class BaseModelSqlv2 {
) )
.from(tQb.as(getAlias())); .from(tQb.as(getAlias()));
selectors.push( selectors.push(
this.dbDriver.raw(`(??) as "??"`, [ this.dbDriver.raw(`(??) as ??`, [subQuery, `${f.alias}`]),
subQuery,
this.dbDriver.raw(f.alias),
]),
); );
break; break;
case 'mysql2': case 'mysql2':
@ -1597,12 +1591,7 @@ class BaseModelSqlv2 {
tQb.select(jsonBuildObject); tQb.select(jsonBuildObject);
selectors.push( selectors.push(this.dbDriver.raw(`(??) as ??`, [tQb, `${f.alias}`]));
this.dbDriver.raw(`(??) as ??`, [
tQb,
this.dbDriver.raw(`"${f.alias}"`),
]),
);
} }
qb.select(...selectors); qb.select(...selectors);

10
packages/nocodb/src/services/meta-diffs.service.ts

@ -448,7 +448,10 @@ export class MetaDiffsService {
} }
for (const relation of relationList) { 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 changes
.find((t) => t.table_name === relation.tn) .find((t) => t.table_name === relation.tn)
?.detectedChanges.push({ ?.detectedChanges.push({
@ -462,7 +465,10 @@ export class MetaDiffsService {
cstn: relation.cstn, 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 changes
.find((t) => t.table_name === relation.rtn) .find((t) => t.table_name === relation.rtn)
?.detectedChanges.push({ ?.detectedChanges.push({

Loading…
Cancel
Save