getScalarResult does not return integer or floats as correct type #6091

Closed
opened 2026-01-22 15:26:38 +01:00 by admin · 3 comments
Owner

Originally created by @alexander-schranz on GitHub (Oct 30, 2018).

Originally assigned to: @Ocramius on GitHub.

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.

Originally created by @alexander-schranz on GitHub (Oct 30, 2018). Originally assigned to: @Ocramius on GitHub. ### 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.
admin added the BugCan't FixInvalid labels 2026-01-22 15:26:38 +01:00
admin closed this issue 2026-01-22 15:26:39 +01:00
Author
Owner

@Ocramius commented on GitHub (Nov 4, 2018):

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 commented on GitHub (Nov 4, 2018): 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`.
Author
Owner

@alexander-schranz commented on GitHub (Nov 5, 2018):

@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.

@alexander-schranz commented on GitHub (Nov 5, 2018): @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.
Author
Owner

@Ocramius commented on GitHub (Nov 5, 2018):

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
.

@Ocramius commented on GitHub (Nov 5, 2018): 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> .
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6091