Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#2007 closed bug (fixed)

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

Reported by: marisn Owned by: nobody
Priority: major: does not work as expected Milestone:
Component: Vectors Version: Trunk
Keywords: SQL Cc:
Must Fix for Release: No Platform: Gentoo
Platform Version: Awaiting user input: yes

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.

Attachments (1)

cities.zip (1.4 KB ) - added by marisn 14 years ago.
Sample dataset for bug reproduction

Download all attachments as: .zip

Change History (7)

comment:1 by jef, 14 years ago

Awaiting user input: set

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?

comment:2 by lutra, 14 years ago

Not replicable here too.

comment:3 by marisn, 14 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.

by marisn, 14 years ago

Attachment: cities.zip added

Sample dataset for bug reproduction

comment:4 by lutra, 14 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

in reply to:  description comment:5 by jef, 14 years ago

Resolution: fixed
Status: newclosed

Replying to marisn:

  • Open attribute table;
  • Open query builder;

Ouch, sorry, totally misread your report.

I implied this was about the QgsQueryBuilder, but it's about QgsSearchQueryBuilder.

Fixed in r11804

comment:6 by marisn, 14 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 :)

Note: See TracTickets for help on using tickets.