fid filter may be ambiguous if there's an actual attribute named ID

Description

The ECQL grammar does not allow to create an IN filter on an attribute called ID: ID IN (1, 2, 3) is meant as a fid filter.
Some time ago it was proposed that the fid filter were created through a special token @id instead: http://www.mail-archive.com/geotools-devel@lists.sourceforge.net/msg07018.html - http://www.mail-archive.com/geotools-devel@lists.sourceforge.net/msg07018.html.

The following test case exemplifies it:

Index: src/test/java/org/geotools/filter/text/ecql/ECQLINPredicateTest.java
===================================================================
— src/test/java/org/geotools/filter/text/ecql/ECQLINPredicateTest.java (revision 33330)
+++ src/test/java/org/geotools/filter/text/ecql/ECQLINPredicateTest.java (working copy)
@@ -17,6 +17,7 @@

org.geotools.filter.text.ecql;

+ java.util.Arrays;
java.util.Iterator;
java.util.LinkedList;
java.util.List;
@@ -46,6 +47,25 @@

/**
+ * Say there's an attribute named and you want to build an IN filter on it...
+ * sample: ID IN (1,2,3)
+ * @ CQLException
+ */
+ @Test
+ CQLException{
+
+ List<
+ ;
+ txtPredicate = makeInPredicate(propName, intList);
+
+ Filter filter = ECQL.toFilter( txtPredicate);
+
+ commonAssertForInPredicate(filter);
+
+ assertFilterHasProperty((Or)filter, propName);
+ }
+
+ /**

  • sample: length IN (4100001)

  • @ CQLException
    */

and produces the parse error:

org.geotools.filter.text.cql2.CQLException: Encountered "ID IN ( 1" at line 1, column 1.
Was expecting one of:
<NOT> ...
"(" ...
"[" ...
<IDENTIFIER> ...
"-" ...
<INTEGER_LITERAL> ...
<FLOATING_LITERAL> ...
<STRING_LITERAL> ...
"true" ...
"false" ...
"point" ...
"linestring" ...
"polygon" ...
"multipoint" ...
"multilinestring" ...
"multipolygon" ...
"geometrycollection" ...
"envelope" ...
"id" ...
"id" <NOT> ...
"id" "in" "(" <STRING_LITERAL> ...
"include" ...
"exclude" ...
. Parsing : ID IN (1,2,3). Current Token : "null"
at org.geotools.filter.text.ecql.ECQLCompiler.compileFilter(ECQLCompiler.java:96)
...

Environment

None

Assignee

Unassigned

Reporter

codehaus

Triage

None

Components

Fix versions

Affects versions

Priority

Medium
Configure