What is the bug or the crash?
####EDITED following discussion with @agiudiceandrea
concat() returns NULL when all arguments are NULL: it should return an empty string see screenshot at comment below
In addition, Preview of the expression result (bottom left corner of expression builder dialog) reports an empty string when concat() returns a NULL value.
####ORIGINAL
strpos("myattribute",'Fell')=True returns NULL when "myattribute" = NULL.
This is undesirable (it should return 0) but understandable.
But in my user case I am using three concatenated fields for the haystack, which converts NULL to empty strings. But
strpos(concat(work1, work2, work3),'Fell') still returns NULL if work1, work2 and work3 are all NULL. I have checked and concat(work1, work2, work3) returns an empty string if if work1, work2 and work3 are all NULL.
Steps to reproduce the issue
Creat a layer (temporary point layer is fine)
Add text fields myfield1 and myfield2
Add 3 features.
In feature 1 leave or set value of myfield1 and myfield2 to Null
In feature 2 leave or set value of myfield1 to 'a' and myfield2 to Null
In feature 3 leave or set value of myfield1 to 'Fell' and myfied2 to Null
Create an Advanced Filter Expression
For the expression enter strpos(concat(myfield1, myfield2),'Fell')
This expresion will return NULL for feature 1, 0 for feature 2 and 1 for feature 3.
This expresion SHOULD return 0 for feature 1, 0 for feature 2 and 1 for feature 3.
Versions
| QGIS version | 3.44.8-Solothurn |
| QGIS code revision | d25052deb8b |
| |
| Libraries |
| Qt version | 5.15.13 |
| Python version | 3.12.13 |
| GDAL version | 3.12.2 (Compiled) 3.12.3 (Running) — Chicoutimi |
| PROJ version | 9.8.0 (Compiled) 9.7.1 (Running) |
| EPSG Registry database version | v12.029 (2025-10-03) |
| GEOS version | 3.14.1-CAPI-1.20.5 |
| SQLite version | 3.50.4 |
| PDAL version | 2.10.0 |
| PostgreSQL client version | 17.3 |
| SpatiaLite version | 5.1.0 |
| QWT version | 6.3.0 |
| QScintilla2 version | 2.14.1 |
| OS version | Windows 10 Version 2009 |
| |
| Active Python plugins |
| AnotherDXF2Shape | 1.4.2 |
| GeoCoding | 2.19 |
| magic_map_loader | 1.2 |
| processing_saga_nextgen | 1.1.0 |
| processing_umep | 2.2.8 |
| qfieldsync | v4.18.3 |
| quick_map_services | 1.1.0 |
| splitmultipart | 1.0.0 |
| db_manager | 0.1.20 |
| processing | 2.12.99 |
Supported QGIS version
New profile
No Duplicate of the Issue
Additional context
No response
What is the bug or the crash?
####EDITED following discussion with @agiudiceandrea
concat() returns NULL when all arguments are NULL: it should return an empty string see screenshot at comment below
In addition, Preview of the expression result (bottom left corner of expression builder dialog) reports an empty string when concat() returns a NULL value.
####ORIGINAL
strpos("myattribute",'Fell')=Truereturns NULL when "myattribute" = NULL.This is undesirable (it should return 0) but understandable.
But in my user case I am using three concatenated fields for the haystack, which converts NULL to empty strings. But
strpos(concat(work1, work2, work3),'Fell')still returns NULL if work1, work2 and work3 are all NULL. I have checked and concat(work1, work2, work3) returns an empty string if if work1, work2 and work3 are all NULL.Steps to reproduce the issue
Creat a layer (temporary point layer is fine)
Add text fields myfield1 and myfield2
Add 3 features.
In feature 1 leave or set value of myfield1 and myfield2 to Null
In feature 2 leave or set value of myfield1 to 'a' and myfield2 to Null
In feature 3 leave or set value of myfield1 to 'Fell' and myfied2 to Null
Create an Advanced Filter Expression
For the expression enter strpos(concat(myfield1, myfield2),'Fell')
This expresion will return NULL for feature 1, 0 for feature 2 and 1 for feature 3.
This expresion SHOULD return 0 for feature 1, 0 for feature 2 and 1 for feature 3.
Versions
3.12.3 (Running) — Chicoutimi
9.7.1 (Running)
Supported QGIS version
New profile
No Duplicate of the Issue
Additional context
No response