﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
15101	GeoQuerySet extent() method fails to limit	billtown@…	nobody	"I have an object with geometry points.

I expected to be able to return 100 objects' extent using a limit.  However as demonstrated below the limit is never in the raw sql query:
{{{
#!python
>>> test = SamAddress.objects.all()[:100].extent()
>>> print test;
(-84.390510000000006, 33.754629999999999, -77.678370000000001, 40.513269999999999)

>>> test = SamAddress.objects.all().extent()
>>> print test;
(-84.390510000000006, 33.754629999999999, -77.678370000000001, 40.513269999999999)
}}}

Debug from postgres.....
{{{
2011-01-16 18:45:04 EST LOG:  statement: SELECT ST_Extent(""world_samaddress"".""geometry"") AS ""geoagg"" FROM ""world_samaddress""

2011-01-16 18:45:13 EST LOG:  statement: SELECT ST_Extent(""world_samaddress"".""geometry"") AS ""geoagg"" FROM ""world_samaddress""
}}}

This actually makes sense since `ST_Extent` is indeed an aggregate function and cannot be limited (similar to `count()` or `sum()`).

I am running geodjango 1.2.3.

Version 1.3 alpha 1 SVN-14993 is different in that it does pass through the limits looking like this...

Debug from postgres
{{{
2011-01-16 17:39:10 EST LOG:  statement: SELECT ST_Extent(""world_samaddress"".""geometry"") AS ""geoagg"" FROM ""world_samaddress limit 100""
}}}

I don't know why my version does not use the limits on extent() and or count().
However the return value would still be the aggregate and not the limited results.
{{{
select ST_Extent(geometry) from world_samaddress limit 1;

BOX(-84.39051 33.75463,-77.67837 40.51327)

select ST_Extent(geometry) from world_samaddress;

BOX(-84.39051 33.75463,-77.67837 40.51327)
}}}
The same would go for count() (or any aggregate function?

In future versions if a subselect were used it would do what I wanted it to do (which is odd) but return the extent of 100 points.
{{{
 select ST_Extent(geometry) from (select geometry from world_samaddress limit 1) as foo;

 BOX(-84.39051 33.75463,-84.39051 33.75463)

 select ST_Extent(geometry) from (select geometry from world_samaddress) as foo;
 
 BOX(-84.39051 33.75463,-77.67837 40.51327)
}}}"		new	GIS	1.2			extent()		Unreviewed	0	0	0	0		
