#5153 closed defect (fixed)
OGR SQL: confusion between literal that is equal to a column name
Reported by: | nirvn | Owned by: | warmerdam |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | OGR_SF | Version: | 1.9.0 |
Severity: | major | Keywords: | ogr sql |
Cc: |
Description
I've just hit a really strange bug. Using the attached shapefile, OGR Shapefile driver is unable to query the dataset using a simple string attribute filter and return "error 1: type mismatch or improper type of arguments to = operator".
Steps to reproduce:
- Use the following ogrinfo command line on the attached shapefile:
ogrinfo -al -where "PARTY_1ST = 'CPP'" "election 2012\commune_election_results_v2.shp"
This will fail, returning error 1
- Use the following ogrinfo command line on the attached shapefile:
ogrinfo -al -where "PARTY_1ST = 'HRP'" "election 2012\commune_election_results_v2.shp"
This will fail, returning error 1
- Use the following ogrinfo command line on the attached shapefile:
ogrinfo -al -where "PARTY_1ST = 'Sam Rainsy'" "election 2012\commune_election_results_v2.shp"
This will work and list the filtered features.
Change History (5)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Hum, the issue here is that the OGR SQL engine confuses the 'CPP' litteral and the CPP column. This is indeed a known issue listed in paragraph 'More stricter OGR SQL syntax to distinguish literals from identifiers' of http://trac.osgeo.org/gdal/wiki/GDAL20Changes.
One way of workarounding this for wnow is to ogr2ogr your shapefile to sqlite and then issue the request on the sqlite file.
comment:3 by , 11 years ago
Summary: | ogr shapefile driver unable to apply simple string attribute filter → OGR SQL: confusion between literal that is equal to a column name |
---|
comment:4 by , 9 years ago
Component: | default → OGR_SF |
---|---|
Keywords: | ogr sql added |
Milestone: | → 2.0 |
Resolution: | → fixed |
Status: | new → closed |
Has been implement per http://trac.osgeo.org/gdal/wiki/rfc52_strict_sql_quoting
Oups, turns out the shapefile is over attachment's size limit. I've uploaded the shapefile to this location: http://licadho-cambodia.org/gdal/Election2012.zip