On Sat, Oct 8, 2011 at 6:24 PM, <[email protected]> wrote:
> Hi, Andrea
>
> I am about to finish my DB2FunctionTest. At the moment, there is only a
> postgis implementation PostgisFunctionTest.
>
> Some tests give me headaches. "testEuqalsIgnoreCase" is a good example. The
> resulting postgis sql string is:
>
> SELECT "id",encode(ST_AsBinary(ST_Force_2D("geometry")),'base64') as
> "geometry","intProperty","doubleProperty","stringProperty" FROM
> "public"."ft1" WHERE (lower("stringProperty") = lower('ZeRo'::text)) = true
>
> The part after the were clause is interesting:
>
> (lower("stringProperty") = lower('ZeRo'::text)) = true
>
> Normally,
>
> (lower("stringProperty") = lower('ZeRo'::text))
>
> should be sufficient.
>
> I have no chance to formulate "= true" in DB2 and I am not sure if other
> databases support this construct.
>
> Is there a special reason for that ?.
> Should I override such test methods ?
I guess you might. The filter to be encoded is:
Function func = ff.function("strEqualsIgnoreCase",
ff.property(aname("stringProperty")), ff.literal("ZeRo"));
Filter filter = ff.equals(func, ff.literal(true));
and what we have in the test is the literal translation of that expression,
which, for increased readability as cql is:
strEqualsIgnoreCase(stringProperty, "ZeRo") = true
where strEqualsIgnoreCase is a function (and yes, I know the same filter
can be expressed in OGC filter using a non case sensitive property is equal
to, but that's not the point of the exercise, which is instead to see if you
can encode that kind of filter function).
If you want to do it in a different way, without the equality to true,
I believe you are free to,
specifically for DB2 of course.
Or you can just say that DB2 cannot encode that particular function.
See, the whole point of the work I did was to see how filter functions
could be encoded
in sql, without any objective to encode them all, I was more looking
for a certain variety
to see what kind of troubles one might encounter while encoding them.
I don't actually expect anyone to use much strEqualsIgnoreCase in
practice, though
it might be useful in case you need to provide it as a parameter to
another function,
for example:
if_then_else(strEqualsIgnoreCase(stringProperty, "ZeRo"), "0xFF0000",
"0x00FF00")
(and even this one could be done in a different way, but I guess you
get the point anyways).
As for, why the "= true", because the filter function per se is not a
filter, it is an expression,
to make it into a filter you have to compare its result with true
(turning it into a PropertyIsEqualsTo
filter).
Cheers
Andrea
--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf
-------------------------------------------------------
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel