Orm: getScalarResult does not return integer or floats as correct type

Created on 30 Oct 2018  Â·  3Comments  Â·  Source: doctrine/orm

Bug Report

| Q | A
|------------ | ------
| BC Break | no sure?
| Version | 2.6.2

Summary

getScalarResult does not return integer or floats just strings it should convert scalar fields like integer, floats into the correct format.

Current behavior

getScalarResult return all columns as strings instead of scalar values.

How to reproduce

Use getScalarResult on a query which should return integer, float fields.

Expected behavior

getScalarResult should return scalar types in correct type instead of string. Maybe add a new method getRawResult for returning all fields as string.

Bug Can't Fix Invalid

Most helpful comment

@Ocramius thx for your answer. Think getScalarResult is misleading and should maybe be renamed in the next major release then. And then a hydration mode which really return only scalar values could be introduced.

All 3 comments

This is correct and expected, since there is no way for the ORM to know what kind of mapping is to be used for a retrieved value.

Should we use the DQL AST to decide what kind of type the retrieved value should have, then we'd be introducing a BC break for consumers that rely on the value being string right now.

Closing as invalid.

@Ocramius thx for your answer. Think getScalarResult is misleading and should maybe be renamed in the next major release then. And then a hydration mode which really return only scalar values could be introduced.

We can maybe add a method, and deprecate this one, but changing it is too
risky, given the amount of consumers.

On 5 Nov 2018 10:34, "Alexander Schranz" notifications@github.com wrote:

@Ocramius https://github.com/Ocramius thx for your answer. Think
getScalarResult is misleading and should maybe be renamed in the next major
release then. And then a hydration mode which really return only scalar
values could be introduced.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7447#issuecomment-435810535,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakORKhJ6VbTHkmU22Cjyi8An3A0QMks5usAYxgaJpZM4YBoaU
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

weaverryan picture weaverryan  Â·  3Comments

doctrinebot picture doctrinebot  Â·  4Comments

doctrinebot picture doctrinebot  Â·  3Comments

kcassam picture kcassam  Â·  3Comments

delboy1978uk picture delboy1978uk  Â·  3Comments