Skip to content

Commit

Permalink
Fix m2m2r chain post filter (finos#3111)
Browse files Browse the repository at this point in the history
Co-authored-by: Sai Sriharsha Annepu <[email protected]>
  • Loading branch information
Paarth002 and gs-ssh16 authored Sep 22, 2024
1 parent 74e37d0 commit 3cbe194
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Any>).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<Any>).owner == TDSRow || $fe.func->evaluateAndDeactivate()->cast(@QualifiedProperty<Any>)->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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,44 @@ function <<test.Test>> 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 <<test.Test>> 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
}
)

0 comments on commit 3cbe194

Please sign in to comment.