Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

count return string instead of number #68

Open
olegsklyarov1972 opened this issue Dec 15, 2022 · 3 comments
Open

count return string instead of number #68

olegsklyarov1972 opened this issue Dec 15, 2022 · 3 comments

Comments

@olegsklyarov1972
Copy link

Could you please explain if I run the query:
DB::connection('clickhouse')->select(raw('select count(*) as summary from table'));
I get the result like this
array:1 [
0 => array:1 [
"summary" => "4309900"
]
]

Why "summary" get "4309900" as string, not a number ?

@evsign
Copy link
Collaborator

evsign commented Dec 15, 2022

It's the way clickhouse sends data in JSON format. You could repeat your query with the format section added in clickhouse-client, and you'll see the same result.
To be fair, clickhouse now sends additional meta information with the types for the returned values (not sure it was so before), and we could implement casting of these values. But this feature is currently not implemented in the library, and no one thought about it.

@olegsklyarov1972
Copy link
Author

Could you add this feature?

@evsign
Copy link
Collaborator

evsign commented Dec 16, 2022

Not anytime soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants