1

I have layer in qgis. It has an attribute data_count (Integer) and a value (String).

When I filer for "value" ~ 'maximum-speed-limit' it works. When I filter for "data_count" > 10 it works as well. But when I use "data_count" > 5 AND "value" ~ 'maximum-speed-limit' it says error:

An error occurred when executing the query.
The data provider said:
OGR[3] error 1: SQL Expression Parsing Error: syntax error, unexpected $undefined, expecting end of string. Occurred around :
"data_count" > 5 AND "value" ~ 'maximum-speed-limit'

But if I don't use regexp, but use LIKE instead, it works perfectly : "data_count" > 5 AND "value" LIKE '%maximum-speed-limit%'

Why is that happening? I tried and see that other "more complicated" regexp expressions don't work either, like "value" ~'[0-9].*. But then why the simple "somevalue"~'sometext' works? I have read the QGIS documentation but the answer is not clear to me.

3
  • 1
    Where are you applying this expression, in which dialog?
    – Mayo
    Commented Mar 5 at 21:00
  • 1
    If this is the Layer Filter dialog, please also specify which filetype/datasource your layer is in (shp, gpkg, postgres etc.). I believe ~ is not supported in Layer Filter for OGR layers, (defaults to SQLite which does not support ~ unlike Postgres). Can you confirm that when you say "value" ~ 'maximum-speed-limit' works, it actually filters the results correctly, rather than just not throwing up an error message? Because with gpkg and a simple ~ expression, if I press Test it shows an error, but if I press OK it silently lets me through - however there are no filtered results.
    – she_weeds
    Commented Mar 6 at 3:13
  • It is an imported GeoJSON and I used it in the Layer Filter dialog. I am quite sure that I pressed "Test" and "Ok" as well and it worked, but today I cannot reproduce it. So I will just delete my question. Thanks for the answer!
    – 588chm
    Commented Mar 7 at 6:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.