This path fix : http://www.doctrine-project.org/jira/browse/DDC-657
Has been added the declaring class in a scalar result, that allow get the type from the field mapping.
Please tell me if can I make something better.
tests for DDC-657
added some tests
code refactoring and other tests
Hi @FabioBatSilva !
This patch can be optimized, for sure.
Since you always addScalarResult to a Column (and not a class), it may be better if you provide the typeMapping. That way, in AbstractHydrator you don't need to lookup again on ClassMetadata, you can just grab directly the Type and convert.
As soon as you finish this change, feel free to poke me, I'll merge right away. =)
This would be changed from $class->name to $class->fieldMappings[$fieldName]['type']
Please try to find also other possible remaining calls to addScalarResult in SqlWalker. =)
You won't need this block anymore. Just:
$cache[$key]['type'] = $this->_rsm->typeMappings[$key];
You can assume the "type" will be always present.
Just grab the Type and convert right away.
You can create a minor BC break since this will be only merged to 2.3.
All you can do is enforce the $type to be set.
Just don't forget to add that to CHANGELOG for 2.3
You can prevent the BC break if you do:
$this->typeMappings[$columnName] = $type ?: 'string';
This would become $typeMappings property
In ea14bcf I applied a patch that solves this issue, but credits totally goes for, since all I've done is actually use your patch and applied the changes I suggested to you.
I was too busy on the last days then I could not apply yours sugestions.
Anyway thanks for your comments and for the credits in the new commit. :)