[DDC-657] Convert scalar value if it's an entity field #251

Closed
wants to merge 4 commits into from

2 participants

@FabioBatSilva
Doctrine member

Hello,

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.

Thanks..

@guilhermeblanco
Doctrine member

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. =)

Cheers,

@guilhermeblanco

This would be changed from $class->name to $class->fieldMappings[$fieldName]['type']

Doctrine member

Please try to find also other possible remaining calls to addScalarResult in SqlWalker. =)

@guilhermeblanco

You won't need this block anymore. Just:

$cache[$key]['type'] = $this->_rsm->typeMappings[$key];
@guilhermeblanco

You can assume the "type" will be always present.
Just grab the Type and convert right away.

@guilhermeblanco

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

Doctrine member

You can prevent the BC break if you do:

$this->typeMappings[$columnName] = $type ?: 'string';

@guilhermeblanco

This would become $typeMappings property

@guilhermeblanco
Doctrine member

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.

@FabioBatSilva
Doctrine member

Sorry @guilhermeblanco,
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. :)

@FabioBatSilva FabioBatSilva deleted the FabioBatSilva:DDC-657 branch Jan 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment