mirror of
https://github.com/nocodb/nocodb.git
synced 2026-02-02 02:37:33 +00:00
Merge pull request #12816 from nocodb/nc-fix/oss-ltar-test
fix: test for "will create a formula referencing lookup referencing formula"
This commit is contained in:
@@ -255,12 +255,23 @@ export const selectObject = (baseModel: IBaseModelSqlV2, logger: Logger) => {
|
||||
validateFormula,
|
||||
aliasToColumnBuilder,
|
||||
);
|
||||
qb.select(
|
||||
baseModel.dbDriver.raw(`?? as ??`, [
|
||||
selectQb.builder,
|
||||
getAs(column),
|
||||
]),
|
||||
);
|
||||
|
||||
if ('toQuery' in selectQb.builder) {
|
||||
const selectQbQuery = selectQb.builder.toQuery();
|
||||
qb.select(
|
||||
baseModel.dbDriver.raw(
|
||||
`${selectQbQuery.replaceAll('?', '\\?')} as ??`,
|
||||
[getAs(column)],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
qb.select(
|
||||
baseModel.dbDriver.raw(`?? as ??`, [
|
||||
selectQb.builder,
|
||||
getAs(column),
|
||||
]),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.log(e);
|
||||
// return dummy select
|
||||
|
||||
@@ -665,12 +665,13 @@ export const lookupOrLtarBuilder =
|
||||
break;
|
||||
}
|
||||
|
||||
if (selectQb)
|
||||
if (selectQb) {
|
||||
return {
|
||||
builder:
|
||||
typeof selectQb === 'function'
|
||||
? selectQb
|
||||
: knex.raw(selectQb as any).wrap('(', ')'),
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import 'mocha';
|
||||
import { runOnSet } from '../../utils/runOnSet';
|
||||
import { pgTemporaryTableTests } from './temporaryTable.test';
|
||||
import { isEE } from '../../utils/helpers';
|
||||
|
||||
function _pgDBQueryClientTests() {
|
||||
pgTemporaryTableTests();
|
||||
}
|
||||
|
||||
export const pgDBQueryClientTests = runOnSet(2, function () {
|
||||
if (isEE()) {
|
||||
describe('PGDBQueryClientTests', _pgDBQueryClientTests);
|
||||
}
|
||||
describe('PGDBQueryClientTests', _pgDBQueryClientTests);
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { expect } from 'chai';
|
||||
import 'mocha';
|
||||
import { ClientType } from 'nocodb-sdk';
|
||||
import { initInitialModel } from '../initModel';
|
||||
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
|
||||
import { PGDBQueryClient } from '~/dbQueryClient/pg';
|
||||
@@ -27,6 +28,9 @@ function pgTemporaryTableTest() {
|
||||
});
|
||||
|
||||
it(`will generate a temporary table`, async () => {
|
||||
if (_source!.type !== ClientType.PG) {
|
||||
return;
|
||||
}
|
||||
const data = [
|
||||
{ id: 1, foo: 'foo1', bar: 'bar1' },
|
||||
{ id: 2, foo: 'foo2', bar: 'bar2' },
|
||||
|
||||
@@ -530,6 +530,14 @@ export async function initFormulaLookupColumns(context: ITestContext) {
|
||||
relationColumnId: t3_OO_t1_Ltar.id,
|
||||
});
|
||||
|
||||
// referencing using formula field so it's populated in chunkList
|
||||
await createColumn(context.context, context.tables.table3, {
|
||||
title: 'table1FormulaTitleFormula',
|
||||
uidt: UITypes.Formula,
|
||||
formula: `{table1FormulaTitle}`,
|
||||
formula_raw: `{table1FormulaTitle}`,
|
||||
});
|
||||
|
||||
for (const attr of t1SupportingLookupColumns) {
|
||||
await createLookupColumn(context.context, {
|
||||
base: context.base,
|
||||
|
||||
@@ -4,7 +4,6 @@ import { expect } from 'chai';
|
||||
import { initFormulaLookupColumns, initInitialModel } from '../initModel';
|
||||
import { createColumn } from '../../factory/column';
|
||||
import { chunkListRow, listRow } from '../../factory/row';
|
||||
import { isEE } from '../../utils/helpers';
|
||||
|
||||
function formulaLookupLtarTests() {
|
||||
let _setup;
|
||||
@@ -279,11 +278,6 @@ function formulaLookupLtarTests() {
|
||||
|
||||
// issue #11299
|
||||
it('will create a formula referencing lookup referencing formula', async () => {
|
||||
// TODO: enable and fix for OSS
|
||||
if (!isEE()) {
|
||||
return;
|
||||
}
|
||||
|
||||
await initFormulaLookupColumns(_setup);
|
||||
const _formulaColumn = await createColumn(_context, _tables.table2, {
|
||||
title: 'table1FormulaTitleConcat',
|
||||
@@ -303,6 +297,14 @@ function formulaLookupLtarTests() {
|
||||
expect(parts[1]).to.contain(token);
|
||||
}
|
||||
|
||||
// referencing using formula field so it's populated in chunkList
|
||||
await createColumn(_context, _tables.table1, {
|
||||
title: 'table2FormulaTitleFormula',
|
||||
uidt: UITypes.Formula,
|
||||
formula: `{table2FormulaTitle}`,
|
||||
formula_raw: `{table2FormulaTitle}`,
|
||||
});
|
||||
|
||||
const t1Rows = await chunkListRow({
|
||||
base: _base,
|
||||
table: _tables.table1,
|
||||
@@ -318,9 +320,9 @@ function formulaLookupLtarTests() {
|
||||
table: _tables.table3,
|
||||
pks: [1, 2, 3, 4, 5, 6].map((k) => `${k}`),
|
||||
});
|
||||
expect(t1Rows[0].table2FormulaTitle).to.eq('T2_001?');
|
||||
expect(t1Rows[0].table2FormulaTitleFormula).to.eq('T2_001?');
|
||||
expect(t2Rows[0].table1FormulaTitleConcat).to.contain('T1_001?');
|
||||
expect(t3Rows[0].table1FormulaTitle).to.eq('T1_001?');
|
||||
expect(t3Rows[0].table1FormulaTitleFormula).to.eq('T1_001?');
|
||||
});
|
||||
|
||||
it('will create a formula column assigned as display value accessed through ltar field', async () => {
|
||||
|
||||
Reference in New Issue
Block a user