diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/store/m2m/chain.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/store/m2m/chain.pure index 2a4020fef7f..2126b4feb7d 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/store/m2m/chain.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/store/m2m/chain.pure @@ -366,7 +366,7 @@ function meta::pure::mapping::modelToModel::chain::inlineQualifiedProperties(vs: { $vs->match([ - fe : FunctionExpression[1] | if(($fe.func->evaluateAndDeactivate()->instanceOf(QualifiedProperty) && !($fe.func->evaluateAndDeactivate()->cast(@QualifiedProperty).owner == TDSRow)) || ($fe.func->instanceOf(ConcreteFunctionDefinition) && !($fe.func->evaluateAndDeactivate()->instanceOf(NativeFunction) || $fe.func->evaluateAndDeactivate()->meta::pure::router::routing::shouldStop($extensions))), + fe : FunctionExpression[1] | if(($fe.func->evaluateAndDeactivate()->instanceOf(QualifiedProperty) && !($fe.func->evaluateAndDeactivate()->cast(@QualifiedProperty).owner == TDSRow || $fe.func->evaluateAndDeactivate()->cast(@QualifiedProperty)->functionType().parameters->evaluateAndDeactivate()->at(0).genericType.rawType == TDSRow)) || ($fe.func->instanceOf(ConcreteFunctionDefinition) && !($fe.func->evaluateAndDeactivate()->instanceOf(NativeFunction) || $fe.func->evaluateAndDeactivate()->meta::pure::router::routing::shouldStop($extensions))), | let newParams = $fe.parametersValues->evaluateAndDeactivate()->map(x | $x->inlineQualifiedProperties($vars, $openVars, $oldVar, $extensions)); let newFe = ^$fe(parametersValues = $newParams); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSFilter.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSFilter.pure index 6ed8ac5f410..bec189acad3 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSFilter.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSFilter.pure @@ -273,3 +273,44 @@ function <> meta::relational::tests::tds::tdsFilter::testFirstNotNull assertEquals('select "root".FIRSTNAME as "firstName" from personTable as "root" where (coalesce("root".FIRSTNAME, \'N/A\') <> \'N/A\' OR coalesce("root".FIRSTNAME, \'N/A\') is null)', $result->sqlRemoveFormatting()); } + +function <> meta::relational::tests::tds::tdsFilter::testChainPostFilter():Boolean[1] +{ + let result = execute( + |meta::relational::tests::tds::tdsFilter::PersonV2.all() + ->project(p | $p.firstName, 'firstName') + ->filter(p | $p.getString('firstName') == 'John'), + meta::relational::tests::tds::tdsFilter::PersonMappingV2, + ^meta::core::runtime::Runtime( + connectionStores = [ + ^meta::core::runtime::ConnectionStore(element = meta::relational::tests::dbInc, connection = meta::external::store::relational::tests::testRuntime().connectionStores->filter(c | $c.element == meta::relational::tests::db)->toOne().connection), + ^meta::core::runtime::ConnectionStore(element = ^meta::external::store::model::ModelStore(), connection = ^meta::external::store::model::ModelChainConnection(mappings = meta::relational::tests::simpleRelationalMappingInc)) + ] + ), + meta::relational::extension::relationalExtensions() + ); + + assertSize($result.values.columns, 1); + assertEquals('John,John', $result.values.rows->map(r|$r.values->makeString('|'))->makeString(',')); +} + +Class meta::relational::tests::tds::tdsFilter::PersonV2 +{ + firstName : String[1]; + lastName : String[1]; + age : Integer[0..1]; +} + +###Mapping +Mapping meta::relational::tests::tds::tdsFilter::PersonMappingV2 +( + include meta::relational::tests::simpleRelationalMappingInc + + *meta::relational::tests::tds::tdsFilter::PersonV2: Pure + { + ~src meta::relational::tests::model::simple::Person + firstName: $src.firstName, + lastName: $src.lastName, + age: $src.age + } +)