Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using concat(field1, field2) concatenates 0 instead of empty string ('') if any of the fields is NULL #36112

Closed
tudorbarascu opened this issue Apr 30, 2020 · 2 comments · Fixed by #36521
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Expressions Related to the QGIS expression engine or specific expression functions Feedback Waiting on the submitter for answers

Comments

@tudorbarascu
Copy link
Member

tudorbarascu commented Apr 30, 2020

Describe the bug

How to Reproduce
Using concat(field1, field2) concatenates 0 instead of empty string ('') if field2 is NULL.
The field2 is integer.

For a field1 of text type having value test, field2 type integer and NULL (no value).
A label using concat(field1,field2) expression returns test0 instead of the expected test (adds a 0 instead of an empty string)

I can expand the expression with an IF statement to solve it but.. it's a bug, right?

QGIS and OS versions

QGIS 3.10.5 Windows and Debian Bullseye

@tudorbarascu tudorbarascu added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Apr 30, 2020
@gioman gioman added the Expressions Related to the QGIS expression engine or specific expression functions label Apr 30, 2020
@troopa81 troopa81 self-assigned this May 14, 2020
@troopa81
Copy link
Contributor

I failed to reproduce. In 3.10 and master on Debian bullseye with GeoPackage data.

concat

I tried also with Integer64 and get the same result.

Could you share data sample/project?

@troopa81 troopa81 added the Feedback Waiting on the submitter for answers label May 14, 2020
@tudorbarascu
Copy link
Member Author

Hi @troopa81 I forgon to mention it's a Postgis database, didn't test with anything else. But for Postgis I can always replicate:

Create the following table:

CREATE TABLE bad_concat (id serial PRIMARY KEY, field1 text, field2 integer);

INSERT INTO bad_concat (field1) SELECT 'something';

concat(field1,field2) returns something0

image

Thanks for working on this.

troopa81 added a commit to troopa81/QGIS that referenced this issue May 18, 2020
nyalldawson pushed a commit that referenced this issue May 18, 2020
nyalldawson pushed a commit to nyalldawson/QGIS that referenced this issue May 25, 2020
Fixes qgis#36112 : don't concat null values

(cherry picked from commit 01563e6)
nyalldawson pushed a commit that referenced this issue Jun 19, 2020
Fixes #36112 : don't concat null values

(cherry picked from commit 01563e6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Expressions Related to the QGIS expression engine or specific expression functions Feedback Waiting on the submitter for answers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants