Mauricio Pazos ha scritto: > On Wednesday 26 May 2010 06:04:28 pm Andrea Aime wrote: >> ID IN ('states.1','states.2') and STATE_NAME like 'I%' >> >> and they all worked fine. Only concern is that ID might conflict with >> an existing field. > Let me open the debate in this list. > > In general, you will have problem in ECQL/CQL if you use an language keyword > as field identifier. > By example, if you define a field named LIKE. You will have problem to query > by > the LIKE field. > > LIKE > 1 <<< is not a valid sentence. > > In SQL, the way to save this problem is to define the identifier between > double > quote. By example > > CREATE TABLE test > ( > "LIKE" integer > ) > Then you can ask for > "LIKE" > 1 > > Actually, there are two different symbols: "LIKE" and LIKE. So, in the SQL > language "LIKE" is an identifier and LIKE is the keyword.
What happens in ECQL in that respect? Is there a way to use a keyword as an identifier? > So, how could be solved the problem, if someone wants to define an CQL/ECQL > keyword as property/attribute name in a Layer? I agree a language has keywords and there is nothing that can be done about it. The problem here is that we're superimposing different sets of keywords and rules on the user making it hard to setup a database table that can be used in all contexts. The rule sets I have in mind here are: - what is valid as a database column name - what is valid a XML element (thinking WFS here) - what is valid as ECQL I don't have statistics at hand, but my guess is that ID is a very commonly used column name, especially for primary keys. Primary keys can be exposed as read only attributes from JDBC data stores so we're likely to face complaints once ECQL goes in common use. Possible ways out: - use an identifier that's very unlikely or downright wrong as an attribute name. Something like @id or ::id or id() (just making them up, did not check if I'm actually introducing other problems with any of them). - turn that into a pseudo function call, something like id_in(id1, id2, ..., idn) - have escapes to state ID is intended to be used as an attribute. "ID" would work I guess Cheers Andrea -- Andrea Aime OpenGeo - http://opengeo.org Expert service straight from the developers. ------------------------------------------------------------------------------ _______________________________________________ Geoserver-devel mailing list Geoserver-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-devel