Issues

Issue #7 resolved

Django aggregation unit tests fail

Michael Manfre
repo owner created an issue

Many of //modeltests.aggregation.tests.BaseAggregateTestCase// fail, primarily due to unexpected return type. SQL Server's AVG() will return a value of the same type of the field being averaged. http://msdn.microsoft.com/en-us/library/ms177677.aspx

Example:

{{{ CREATE TABLE ##test ([val] INT) INSERT INTO ##test ([val]) VALUES (1),(2)

-- default behavior, outputs 1 SELECT AVG(val) FROM ##test

-- django unit test compatible behavior, outputs 1.5 SELECT AVG(CAST(val AS FLOAT)) FROM ##test

DROP TABLE ##test }}}

Comments (2)

  1. Michael Manfre reporter

    SQL containing AVG(...) will be modified to cast the contained values to float to allow the function to behave the same as for other databases. E.g. AVG([1,2]) will return 1.5, instead of 1. Casting can be disabled by 'disable_avg_cast' database option. Fixes #7

    Wiki macro error: Changeset 12fed6956dd8 not found.

  2. Log in to comment