Opened 6 years ago

Closed 6 years ago

#5428 closed defect (duplicate)

ogr -where fails if fieldname is identical to value

Reported by: rhaubourg Owned by: warmerdam
Priority: high Milestone:
Component: default Version: unspecified
Severity: major Keywords:
Cc:

Description

Hi, here is a nasty bug caught via QGIS, on GDAL 1.10.1: http://hub.qgis.org/issues/9958

when filtering a file datasource (shp, tab, maybe others) with -where option, if typing an expression like:

"MyField?" = 'MYFIELD', then no filter is applied.

Case seems unrelated, I have also tested with another datasource where "myfield" = 'MYFIELD'

other operators '!=' and '<>' , and 'not like 'MyField?' are affected.

to reproduce, use joined shapefile and test ogrinfo -al -geom=NO -where "TPME = 'TPME'" F:\temp\bug_qgis_filter_fieldname.shp.

You should get 17 features, and 33 are returned. only two values are in that field, you can test "TPME = 'GME'" and this works.

Cheers Régis

Attachments (1)

bug_qgis_fieldnamefilter.zip (239.2 KB) - added by rhaubourg 6 years ago.
shp extract - use TPME field

Download all attachments as: .zip

Change History (2)

Changed 6 years ago by rhaubourg

shp extract - use TPME field

comment:1 Changed 6 years ago by Even Rouault

Resolution: duplicate
Status: newclosed

Yes, this is a known issue that should be corrected at some point. See "More stricter OGR SQL syntax to distinguish literals from identifiers" in http://trac.osgeo.org/gdal/wiki/GDAL20Changes.

I'm closing this bug as a duplicate of #4280 to avoid proliferation of tickets.

A possible workaround with GDAL 1.10 is to use -dialect SQLITE and a full -sql request (not just -where), but that doesn't likely solve the QGIS issue.

Note: See TracTickets for help on using tickets.