SQL generation fix for EOKeyValueQualifiers when key is key path with derived attribute #829
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This bug fix can be disabled by setting the
er.extensions.KeyValueQualifierSQLGenerationSupport.handlesKeyPathWithDerivedAttribute
property tofalse
and everything works just like before. Only one method is overriden and the rest are helper methods.Basically, it overrides
sqlStringForSQLExpression()
inKeyValueQualifierSQLGenerationSupport
which is responsible for generating SQL for key value qualifiers. It does this by first checking for the special case. If it is the special case then it calls the helper method to handle the SQL generation which calls other helper methods. On the other hand, If it is not the special case then it works just like before.The special case fixes SQL generation support for
EOKeyValueQualifiers
when the key consists of two or more keys and the last key references a derived attribute.Example #1:
The the key in the key-value qualifier is
patient.fullNameReversed
and the last key fullNameReversed is defined as:lastName || ', ' || firstName
.Example #2:
A more complex example I tested involves a key-value qualifier with the key
claim.patientAge
wherepatientAge
is a derived attribute that is defined asTRUNC(MONTHS_BETWEEN(dateOfService,patient.birthDate)/12,0)
. My object model has aClaim
entity, aLineItem
entity and aPatient
entity.My test:
This test uses both
patient.fullNameReversed
andclaim.patientAge
Without the fix, EOF throws an exception.
With the fix, the SQL is generated perfectly as follows:
Output