Rails 6.1: Fix failing calculation tests #910
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the following failing CI tests:
The tests needed to be coerced and re-implemented for the following reasons:
AVG() function
In SQL Server the
AVG()function for a list of integers returns an integer. For other databases it would return a decimal. To get SQL Server to return a decimal result the values need to be casted before averaging. so need to cast values as decimals before averaging. So instead ofAVG(credit_limit) AS avg_credit_limitwe need to useAVG(CAST(credit_limit AS DECIMAL) AS avg_credit_limit.SELECT columns must be in the GROUP clause too
SQL Servers queries cannot be:
They need to include all the company's columns in the GROUP clause like:
LIMIT clause
SQL Server does not use the LIMIT clause but FETCH instead.