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

Add a query flag to toggle the type of casting done to Decimals with no decimal places #60

Merged
merged 2 commits into from
Mar 20, 2023

Conversation

nickborromeo
Copy link
Contributor

@nickborromeo nickborromeo commented Mar 18, 2023

In #37 there was a change that updated the value of SUM to be Integer if what is being summed are all Integers. It used to be that it will always return a Decimal type.

When we pulled in that change, there were tests that failed because we were doing arthimitic operations on the result of queries that have SUM. Ruby will have different results if you divide intergers and decimals.

In order to keep that behavior for us (GitHub) while allowing other consumers to use SUM and expect the right type we are introducing a new query flag that we can set in our adapter. This query flag will be what will determine if we should be casting the value of SUM to follow the new behavior or roll back to the old behavior

In #37 there was a change that updated the value of SUM to be Integer if what is
being summed are all Integers. It used to be that it will _always_ return a Decimal type.

When we pulled in that change, there were tests that failed because we were doing arthimitic operations on the result of
queries that have SUM. Ruby will have different results if you divide intergers and decimals.

In order to keep that behavior for us (GitHub) while allows other consumers to use SUM and expect the _right_ type we
are introducing a new query flag that we can set in our adapter. This query flag will be what will determine if we
should be casting the value of SUM to follow the _new_ behavior or roll back to the _old_ behavior
Copy link
Contributor

@composerinteralia composerinteralia left a comment

Choose a reason for hiding this comment

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

The code looks good to me. I think this applies to more than just sum (I wasn't thinking about that as we were browsing sum queries earlier today), so we may need a more general name, but I don't have any good ideas at the moment. Maybe something will come to us over the weekend 😄

@nickborromeo
Copy link
Contributor Author

I think this applies to more than just sum

ah good to know, if that is the case we can generalize it and may use aggregate since that is what SQL buckets those functions in anyway. Maybe something like TRILOGY_FLAGS_CAST_AGGREGATES or TRILOGY_FLAGS_CAST_AGGREGATIONS

@nickborromeo nickborromeo force-pushed the add-query-flag-for-sum-casting branch from f6908ac to a31cefb Compare March 20, 2023 18:51
Copy link
Contributor

@composerinteralia composerinteralia left a comment

Choose a reason for hiding this comment

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

👍🏻

@nickborromeo nickborromeo merged commit dc2f5ed into main Mar 20, 2023
@nickborromeo nickborromeo deleted the add-query-flag-for-sum-casting branch March 20, 2023 19:51
@nickborromeo nickborromeo changed the title Add a query flag to toggle the type of casting done by SUM Add a query flag to toggle the type of casting done to Decimals with no decimal places Mar 20, 2023
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.

None yet

2 participants