Aggregate functions are not escaping attribute names
----------------------------------------------------
Key: GEOT-1798
URL: http://jira.codehaus.org/browse/GEOT-1798
Project: GeoTools
Issue Type: Bug
Affects Versions: 2.5-M1, 2.4.2
Reporter: Andrea Aime
Trying to hit the database using of the aggregate functions like
distict/max/min blows up with postgis if the column is using mixed case letters
because the query is issued like:
select distinct(TotalPopulationSF3) from ...
whilst it should be:
select distinct("TotalPopulationSF3") from ...
Unfortunately fixing this seems hard. The SQL building code has been stuck in
JDBCFeatureCollection, whilst attribute name encoding is something that only
the SQLEncoder does.
JDBCFeatureCollection in the aggregate(aggregate, expression) method is using
SQLBuilder, which has not escaping methods visible and does not provide access
to the SQLEncoder either (and that would be problematic too, since SQLEncoder
is deprecated and the replacement of it it's not in the same
interface/inheritance hierarchy, making it impossible to write code using
either one or the other).
Possible solutions are:
* add a method in SQLBuilder allowing to escape the attribute names (downside,
it's an API change)
* add escaping in JDBCFeatureCollection itself, and have subclasses declare
their own escape char (downside, it duplicates what the SQLBuilder/SQLEncoder
are intended to do)
The basic problem is that JDBCFeatureCollection is trespassing in encoding
land... a proper solution could have been to move the "select" encoding into
SQLBuilder allowing it to accept an array of Expression objects. There are
other problems there too... for example, the expression to be aggregated is
encoded in sql using:
sql.append(expression.toString());
which mean expression need to be coded so that it toStrings to valid sql...
whilst a visit thru the SqlEncoder would have been needed instead.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel