Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix property sequence on routing #3232

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ function meta::pure::mapping::allEnumerationMappings(m: Mapping[1]): Enumeration
$m.enumerationMappings->concatenate($m.includes->map(i | $i.included->allEnumerationMappings()))
}

function meta::pure::mapping::getEnumAndSourceValues(e:meta::pure::mapping::EnumerationMapping<Any>[1]):Pair<String,List<String>>[*]
{
$e.enumValueMappings->map(e|pair($e.enum->id(), list($e.sourceValues->map(s|$s->toString()))));
}

function meta::pure::mapping::allSuperSetImplementations(set :PropertyMappingsImplementation[1], m:Mapping[1]):PropertyMappingsImplementation[*]
{
if ($set.superSetImplementationId->isEmpty(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ function meta::pure::router::routing::resolveVar(va:VariableExpression[1], state
let res = $state.propertyMap.v->filter(p|$p.first == $va.name);
let fullRes = if (!$res->isEmpty(),
|let routed = $res.second->evaluateAndDeactivate()->cast(@ExtendedRoutedValueSpecification)->at(0)->toOne();
^$state(value=^$routed(value = $va));,
^$state(value=^$routed(value = $va, genericType = $va.genericType));,
|^$state(value=$va)
);
print(if($debug.debug,|$debug.space+'~>V) ('+$fullRes.routingStrategy.toString()+') '+$fullRes.value->evaluateAndDeactivate()->cast(@ValueSpecification)->toOne()->asString()+'\n',|''));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3500,8 +3500,11 @@ function <<access.private>> meta::relational::functions::pureToSqlQuery::process

let distinctTransformers = $propertyMappings->filter(m|$m->instanceOf(RelationalPropertyMapping))->cast(@RelationalPropertyMapping).transformer->distinct();
let semiStructuredMappings = $propertyMappings->filter(m|$m->instanceOf(RelationalPropertyMapping))->forAll(x|$x->instanceOf(SemiStructuredRelationalPropertyMapping));
if ($distinctTransformers->size() > 1,
| assertFalse($distinctTransformers->cast(@EnumerationMapping<Any>)->map(e | $e->meta::pure::mapping::getEnumAndSourceValues()->list())->distinct()->size() > 1, 'Unable to determine a unique Enum property mapping for an if stmt (returning an Enum)');,
| [];
);

assertFalse($distinctTransformers->size() > 1, 'Unable to determine a unique Enum property mapping for an if stmt (returning an Enum)');
if ($semiStructuredMappings,
| print(if(!$context.debug, |'', |$context.space+' Ignoring distinct transformer check as all property mappings are semi structured property mappings\n'));,
| assertFalse($distinctTransformers->isEmpty(), 'Unable to determine the Enum property mapping for an if stmt (returning an Enum)');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,3 +449,26 @@ function <<test.Test>> meta::relational::tests::projection::enumeration::testTds
let tds = $result.values->at(0);
assertSize($tds.rows, 3);
}

function <<test.Test>> meta::relational::tests::projection::enumeration::testEnumValueReturnedInIfExpMatch():Boolean[1]
{
let result = execute({|Employee.all()->project(
[
x|$x.type,
x|if(true,
| $x.type,
| $x.type
)
],
[
'Type' ,
'Type If'
]
);
}, employeeTestMapping, enumTestRuntime(), meta::relational::extension::relationalExtensions()
);

assertSameElements($result.values.rows.getEnum('Type If'), $result.values.rows.getEnum('Type'));
let tds = $result.values->at(0);
assertSize($tds.rows, 3);
}
Loading