Aggregate Bug? with ColdFusion (8.0.1) Query of Queries
I've been having the following issue with CF8 Query of Queries on ColdFusion 8.0.2:
Iniital query resultset:
| attraction_latitude | attraction_longitude |
| 51.4808 | -0.155075 |
| 51.564617 | -0.092513 |
| 51.558144 | -0.316379 |
This queryresultset (other fields exist which have been omitted) is passed in to the following cfquery as arguments.attractions
select
min( attraction_latitude ) as min_latitude, max( attraction_latitude ) as max_latitude,
min( attraction_longitude ) as min_longitude, max( attraction_longitude ) as max_longitude
from arguments.attractions
</cfquery>
Aggregate Resultset:
| MAX_LATITUDE | MAX_LONGITUDE | MIN_LATITUDE | MIN_LONGITUDE |
| 51.564617157 | 4.9E-324 | 51.4808006287 | -0.316379010677 |
Eh?
So Max Latitude, Min Latitude and Min Longitude are all calculated correctly - but Max longitude isn't - despite being based on exactly the same data as min longitude?
I can get round it in this particular case by repeating the initial queries against the database (which as expected works correctly).
This certainly looks likes a bug to me, unless I have overlooked something...


Off the top of my head I can't remember the exact issue, but certainly sounds similar to this ;)
<cfset test = QueryNew("testvalue", "Double")>
<cfset rows = 10> <!--- how many rows do we want to test with? --->
<cfset QueryAddRow(test, rows)>
<cfloop index="i" from="1" to="#rows#">
<cfset QuerySetCell(test, "testvalue", RandRange(-10, -1), i)>
</cfloop>
<cfdump var="#test#">
<cfquery name="testMax" dbtype="query">
SELECT MIN(testvalue) AS theMin, MAX(testvalue) AS theMax
FROM test
</cfquery>
<cfdump var="#testMax#">
If I set the values to only be negative numbers, the MAX doesn't work. If I change it to include negative and positives (change the upper limit on the RandRange to a positive), it works fine. Oddly, this is only if I specify the column type as Decimal. If I change it to Integer, it's ok (even though I'm only assigning integers anyway). And I think I've discovered another bug, in RandRange. More on that later perhaps ;-)
<cfset test = QueryNew("testvalue", "Decimal")>
<cfset rows = 10> <!--- how many rows do we want to test with? --->
<cfset QueryAddRow(test, rows)>
<cfloop index="i" from="1" to="#rows#">
<cfset QuerySetCell(test, "testvalue", RandRange(-10, -1), i)>
</cfloop>
<cfdump var="#test#">
<cfquery name="testMax" dbtype="query">
SELECT MIN(testvalue) AS theMin, MAX(testvalue) AS theMax
FROM test
</cfquery>
<cfdump var="#testMax#">
http://duncan99.wordpress.com/2008/07/22/coldfusio...