Bug report #2007

Query builders LIKE statement treats every string like '%string%' with DBF backend

Added by marisn - about 11 years ago. Updated about 11 years ago.

Status:Closed
Priority:Low
Assignee:nobody -
Category:Vectors
Affected QGIS version: Regression?:No
Operating System:Gentoo Easy fix?:No
Pull Request or Patch supplied: Resolution:fixed
Crashes QGIS or corrupts data: Copied to github as #:12067

Description

Steps to reproduce:
  • Open Shapefile;
  • Open attribute table;
  • Open query builder;
  • Create following query:
    mycolumn LIKE 'A%'
    
  • Test result.
    Result set should contain only mycolumn entries that start with "A" letter, still they will contain also any entry that has "A" letter in it. Seems like "%" and "_" are ignored and string is allways treated like "%%" one.

I have no idea if it's only DBF related (limitation?) or not, but as queries in query builder return wrong data sets, something must be done to warn user about QGIS specific SQL dialect, if it's not possible to fix this issue.

cities.zip - Sample dataset for bug reproduction (1.37 KB) marisn -, 2009-10-14 02:18 AM

Associated revisions

Revision 2e1eb256
Added by Jürgen Fischer about 11 years ago

fix #2007

git-svn-id: http://svn.osgeo.org/qgis/trunk/[email protected] c8812cc2-4d05-0410-92ff-de0c093fc19c

Revision 6b4e5263
Added by Jürgen Fischer about 11 years ago

fix #2007

git-svn-id: http://svn.osgeo.org/qgis/[email protected] c8812cc2-4d05-0410-92ff-de0c093fc19c

History

#1 Updated by Jürgen Fischer about 11 years ago

not reproducable here. QGIS uses OGR to access shapefiles and uses OGR SQL to query OGR layers. So this might be a GDAL issue. Which version are you using?

#2 Updated by Giovanni Manghi about 11 years ago

Not replicable here too.

#3 Updated by marisn - about 11 years ago

Good news - it's NOT an GDAL/OGR bug but a QGIS bug :) Tested with 1.6.2 ogrinfo -where and -sql options - OGR returns correct results. QGIS 1.2.0 and current trunk - NOT correct results. I will attach sample dataset.

Steps to reproduce:
  • Open file (UTF-8 coding);
  • Open Attribute table;
  • Advanced search;
  • At SQL where clause enter following text:
    NOSAUKUMS LIKE 'S%'
    
  • Press OK.
    I get 4 results - also "CESIS", still "CESIS" doesn't match 'S%' pattern.

#4 Updated by Giovanni Manghi about 11 years ago

With your sample data and you SQL clause I get 3 (correct) results, so I cannot confirm the problem.

Using qgis trunk compiled under Ubuntu 9.04

#5 Updated by Jürgen Fischer about 11 years ago

  • Status changed from Open to Closed
  • Resolution set to fixed

Replying to marisn:

  • Open attribute table;
  • Open query builder;

Ouch, sorry, totally misread your report.

Fixed in 6b4e5263 (SVN r11805)

#6 Updated by marisn - about 11 years ago

Thanks! Tested - now works just fine. Sorry for confusing description - at first I was using localised QGIS version and thus migh be calling things different than en_US version does :)

Also available in: Atom PDF