qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.61k stars 3.01k forks source link

Value Map Widget NULL value breaks for text field shorter than 38 characters #59368

Open esnyder-rve opened 1 week ago

esnyder-rve commented 1 week ago

What is the bug or the crash?

For some reason, the NULL value is not retained correctly (see steps for more details). What's odd is that this is not consistent. Some attributes don't have this issue, others do. My data is stored in a PostGIS table, where the field is allowed to be NULL (I checked). When running a SELECT DISTINCT the resulting values are correct (with NULL showing as NULL, and not what garbage QGIS is showing). image

However, QGIS is insisting that the value is that uuid string as shown here when the value map widget is setup (it should be NULL): image

Steps to reproduce the issue

  1. Add a layer (in my case is a PostGIS layer)
  2. Go to the Attributes Form settings
  3. Set an attribute's widget type to "Value Map"
  4. Add "NULL" value (looks correct at this point) image
  5. Click "Apply"
  6. Navigate away (by any means) to something else in the UI (such as choosing another attribute)
  7. Go back to the original attribute and find this image

Versions

QGIS version 3.40.0-Bratislava
QGIS code revision b56115d874
Libraries
Qt version 5.15.13
Python version 3.12.7
GDAL/OGR version 3.9.3
PROJ version 9.5.0
EPSG Registry database version v11.016 (2024-08-31)
GEOS version 3.13.0-CAPI-1.19.0
SQLite version 3.46.1
PDAL version 2.8.1
PostgreSQL client version unknown
SpatiaLite version 5.1.0
QWT version 6.3.0
QScintilla2 version 2.14.1
OS version Windows 10 Version 2009
Active Python plugins
db_manager 0.1.20
grassprovider 2.12.99
MetaSearch 0.3.6
processing 2.12.99

Supported QGIS version

New profile

Additional context

At first, I thought it displayed the first value of the Display field for the layer (like how the expression editor shows for the feature preview). However, when I change the display field, this garbage value does not change when deleting and re-adding the NULL option.

esnyder-rve commented 1 week ago
Found the issue. I made a memory layer with text fields of various lengths and got this issue: Field Length Issue?
A 254 No
B 128 No
C 64 No
D 32 Yes
E 38 No
F 37 Yes

Steps to Reproduce:

  1. Create a memory layer
  2. Add a text field with >=38 length
  3. Add a text field with <38 length
  4. Go to the Attributes Form and set each to Value Map, and add a NULL option
  5. Issue will show for the second (<38 length) field
esnyder-rve commented 1 week ago

This issue is not present in the current LTR version.

agiudiceandrea commented 6 days ago

@esnyder-rve, thanks for reporting. The provided steps are enough to replicate the issue even using QGIS 3.38. The issue occurs using QGIS >= 3.38, while it doesn't occur using QGIS <= 3.36.

Hi @elpaso, may you have a look at this? Is it possible that the issue may have been triggered by https://github.com/qgis/QGIS/pull/57690?