From bf164952b289d3fcf1bdaa489fb6809e91df9e3f Mon Sep 17 00:00:00 2001 From: Aziem Chawdhary <61746398+aziemchawdhary-gs@users.noreply.github.com> Date: Wed, 18 Oct 2023 15:50:26 +0100 Subject: [PATCH] Fix router to handle dynamic column specifications (#2381) --- .../core/pure/router/routing/router_routing.pure | 2 +- .../functions/tests/projection/testSimple.pure | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/legend-engine-pure/legend-engine-pure-code/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/routing/router_routing.pure b/legend-engine-pure/legend-engine-pure-code/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/routing/router_routing.pure index 80a447e1d3d..ecb88e86e68 100644 --- a/legend-engine-pure/legend-engine-pure-code/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/routing/router_routing.pure +++ b/legend-engine-pure/legend-engine-pure-code/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/router/routing/router_routing.pure @@ -511,7 +511,7 @@ function meta::pure::router::routing::processColSpecParams(fe:FunctionExpression ]))->cast(@ValueSpecification); let nfe = ^$fe(parametersValues = $parametersValues); - let colSpec = $nfe->reactivate($inScopeVars)->evaluateAndDeactivate()->cast(@ColumnSpecification)->toOne(); + $nfe->reactivate($inScopeVars)->evaluateAndDeactivate()->cast(@ColumnSpecification); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testSimple.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testSimple.pure index 00dd1cee030..d10c214f372 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testSimple.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testSimple.pure @@ -34,6 +34,22 @@ function <> meta::relational::tests::projection::simple::testAllOneSi assertEquals('select "root".FIRSTNAME as "firstName" from personTable as "root"', $result->sqlRemoveFormatting()); } +function meta::relational::tests::projection::simple::getCols():ColumnSpecification[*] +{ + [ + col(x : Person[1] | $x.firstName, 'firstName'), + col(x : Person[1] | $x.lastName, 'lastName') + ]; +} + +function <> meta::relational::tests::projection::simple::testAllOneSimplePropertyWithColsFromFunction():Boolean[1] +{ + let result = execute(|Person.all()->project(meta::relational::tests::projection::simple::getCols()), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); + assertSize($result.values.rows, 7 ); + assertEquals('Allen,Anthony,David,Fabrice,Harris,Hill,Hill,John,John,Johnson,Oliver,Peter,Roberts,Smith', $result.values.rows->map(r|$r.values)->sort()->makeString(',')); + assertEquals('select "root".FIRSTNAME as "firstName", "root".LASTNAME as "lastName" from personTable as "root"', $result->sqlRemoveFormatting()); +} + function <> meta::relational::tests::projection::simple::testAllOneSimplePropertyUsingVariable():Boolean[1] { let p = [#/Person/firstName#];