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

Fixes #1038: type cast fails in select_min/max #1040

Merged
merged 1 commit into from
May 15, 2024

Conversation

davidepaolotua
Copy link
Contributor

Fixes #1038 .
Basically, when we are doing a PG:something -> SomethingElse conversion, it usually works as long as you can cast safely from one another.
Eg: 1 (PG::Int) can be cast to int with .as(Int). Same for strings
However that is not the case for Numeric values - for them the simple .as(Float) does not work - but we need to get through the .to_f method.
This pull request does exactly this, it adds one new method (to_expected_type) with one overload in the specific case of the input being a PG::numeric.
It also fixes the select_max, which was having the same issue

Copy link
Member

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow. Nice find! Yeah, this makes sense, thanks for fixing it!

@jwoertink jwoertink merged commit 52e7521 into luckyframework:main May 15, 2024
8 of 9 checks passed
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

Successfully merging this pull request may close these issues.

[Bug] Cast from PG::Numeric to (Float64 | Nil) failed.
2 participants