Browse Source

qrcode: extract querybuilder logic for formulas

pr-4468-qr-code-extraction
Daniel Spaude 2 years ago
parent
commit
4e9ffc9ca7
No known key found for this signature in database
GPG Key ID: 654A3D1FA4F35FFE
  1. 41
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

41
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -1211,6 +1211,19 @@ class BaseModelSqlv2 {
});
}
private async getSelectQueryBuilderForFormula(column: Column<any>) {
const formula = await column.getColOptions<FormulaColumn>();
if (formula.error) throw new Error(`Formula error: ${formula.error}`);
const selectQb = await formulaQueryBuilderv2(
formula.formula,
null,
this.dbDriver,
this.model
);
return selectQb;
}
async getProto() {
if (this._proto) {
return this._proto;
@ -1438,19 +1451,15 @@ class BaseModelSqlv2 {
switch (qrValueColumn.uidt) {
case UITypes.Formula:
{
const formula =
await qrValueColumn.getColOptions<FormulaColumn>();
if (formula.error) continue;
const selectQb = await formulaQueryBuilderv2(
formula.formula,
null,
this.dbDriver,
this.model
try {
const selectQb = await this.getSelectQueryBuilderForFormula(
qrValueColumn
);
qb.select({
[column.column_name]: selectQb.builder,
});
} catch {
continue;
}
break;
default: {
@ -1463,14 +1472,9 @@ class BaseModelSqlv2 {
}
case 'Formula':
{
const formula = await column.getColOptions<FormulaColumn>();
if (formula.error) continue;
const selectQb = await formulaQueryBuilderv2(
formula.formula,
null,
this.dbDriver,
this.model
// this.aliasToColumn
try {
const selectQb = await this.getSelectQueryBuilderForFormula(
column
);
// todo: verify syntax of as ? / ??
qb.select(
@ -1479,6 +1483,9 @@ class BaseModelSqlv2 {
sanitize(column.title),
])
);
} catch {
continue;
}
}
break;
case 'Rollup':

Loading…
Cancel
Save