[gdal-dev] OGR field names encoding and SetAttributeFilter

Dennis Gocke dengo at gmx.net
Tue Apr 9 05:21:34 PDT 2013


I've done the same test with a PostGIS DB as an example where the filter is
evaluated on the server and not by OGR.

Regarding encoding, everything worked fine when always assuming UTF8
encoding for field names, field values and AttributeFilter.

Although Postgre accepts something like Name = ‘vÄüß’ it also does not
accept Äüß = ‘vÄüß’, but "Äüß" = ‘vÄüß’ works fine.
So It's probably best practice to always use " when specifying field names.
In that regard the OGR QueryFilter works OK.

But Postgre correctly differentiates between " and '.

Cheers,
Dennis



On Tue, Apr 9, 2013 at 11:01 AM, Dennis Gocke <dengo at gmx.net> wrote:

> Thanks Even.
> It's strange that the SQL parser does not accept non-ASCII literals when
> writing "FieldName = .." but when writing
> "'Fieldname' = .." it does. It think this is not good, because it more or
> less encourages the wrong use of ' when specifying field names.
> Is there a reason for this strange behaviour that I'm missing? Perhaps
> this is because without the ' it would confuse the SQL parser when some
> special literals are within the field name (e.g. spaces).
>
> I just noticed you can also use " when specifying field names in OGR, so
> it's not so bad. This is for instance like in ArcMap, but there " can only
> be used when specifying field names and not for specifying strings where '
> needs to be used. It would be nice if OGR would differentiate between ' and
> ", but I agree that might break stuff for people that are used to the
> current behaviour of OGR.
>  So to complete the same example as in the original message (Äüß is the
> name of a field, vÄüß is just a string value):
> Name = ‘vÄüß’ -> no error, correctly filtered
> Äüß = ‘vÄüß’ -> error (SQL Expression Parsing Error: syntax error) (Would
> be nice if this would work)
> 'Äüß' = ‘vÄüß’ -> no error, but it actually filters Äüß = ‘vÄüß’ (IMO this
> should only compare the strings and therefor return no results)
> "Äüß" = ‘vÄüß’ -> no error, and it correctly filters Äüß = ‘vÄüß’
> "Äüß" = "vÄüß" -> no error, but it actually filters Äüß = ‘vÄüß’ (I would
> prefer a parsing error here)
> Regards,
> Dennis
>
>
> On Mon, Apr 8, 2013 at 9:53 PM, Even Rouault <even.rouault at mines-paris.org
> > wrote:
>
>> > About the repacking of shapefiles with .cpg, could you create a ticket
>> > about that ? thanks.
>>
>> I've just fixed that issue in trunk, so you don't need to create a ticket.
>>
>> >
>> > Best regards,
>> >
>> > Even
>> > _______________________________________________
>> > gdal-dev mailing list
>> > gdal-dev at lists.osgeo.org
>> > http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130409/5cb7723d/attachment.html>


More information about the gdal-dev mailing list