Fix raw row fetching issue with composite keypaths and custom classes #1015
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.
This pull request addresses an issue that occurs when you attempt to retrieve raw rows using composite keypaths where the last element is associated with a custom class.
To illustrate the problem, consider the following example:
In this scenario,
User
is the target of theauthor
relationship defined byPost
. Thegender
attribute ofUser
uses a custom class, such as one defined by thejavaEnum
prototype.The issue arises when you use the following code:
The result of this operation is an
NSArray
ofNSDictionary
where the"author.gender"
key returns an object of typeNSData
, rather than the expectedEnum
type.This behavior occurs because the
EOAttribute
constructor is called with theentity
anddefinition
parameters when fetching composite keypaths using raw rows. DuringEOAttribute
initialization, the composite keypath is resolved, and the resultingEOAttribute
behaves as if it were the referenced attribute. However, this only happens if the attribute is flattened. Otherwise, theEOAttribute
is not fully initialized, and theJDBCColumn
is unable to convert the returned data from the database to the correct type.To resolve this issue, I've made changes to ensure that attribute properties are initialized correctly, even if the attribute is not flattened.
I've thoroughly tested this change on a large application, covering both normal and raw rows fetching, and I couldn't find any issues so far. While I don't anticipate any problems arising from these changes, I would appreciate feedback from others on this matter.