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

QGIS inserts empty array into nullable array fields by default when creating new features in a PostGIS layer #38176

Closed
peetw opened this issue Aug 6, 2020 · 3 comments · Fixed by #38785
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@peetw
Copy link

peetw commented Aug 6, 2020

Describe the bug

Given the following PostGIS table schema:

CREATE TABLE test
(
    id SERIAL PRIMARY KEY,
    geom GEOMETRY(LineString, 4326) NOT NULL,
    array INTEGER[]
)

QGIS will insert an empty PostgreSQL array (i.e. {}) into the array field by default when creating new features whilst editing the test PostGIS layer. However, since the array field is nullable (i.e. it is not marked NOT NULL), I would expect QGIS to enter NULL into the array field by default (as this would be the default value if editing the table using other software).

How to Reproduce

See above.

QGIS and OS versions

QGIS version 3.10.7-A Coruña QGIS code revision 7b4ca4c
Compiled against Qt 5.11.2 Running against Qt 5.11.2
Compiled against GDAL/OGR 3.0.4 Running against GDAL/OGR 3.0.4
Compiled against GEOS 3.8.1-CAPI-1.13.3 Running against GEOS 3.8.1-CAPI-1.13.3
Compiled against SQLite 3.29.0 Running against SQLite 3.29.0
PostgreSQL Client Version 11.5 SpatiaLite Version 4.3.0
QWT Version 6.1.3 QScintilla2 Version 2.10.8
Compiled against PROJ 6.3.2 Running against PROJ Rel. 6.3.2, May 1st, 2020
OS Version Windows Server 2016 (10.0)
Active python plugins profiletool; quick_map_services; valuetool; db_manager; MetaSearch; processing

Additional context

@peetw peetw added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Aug 6, 2020
@gioman gioman added the Data Provider Related to specific vector, raster or mesh data providers label Aug 6, 2020
@peetw
Copy link
Author

peetw commented Aug 18, 2020

Happy to help with this one if needed, but not sure where would be a good place to start? I had a quick search through the src files for the source code for the new feature save dialog, but couldn't find anything.

@rouault
Copy link
Contributor

rouault commented Sep 15, 2020

This is not an issue with the Postgres provider, but with the editor widget of an integer list that returns a 0-sized array, and not a NULL value

@gioman gioman removed the Data Provider Related to specific vector, raster or mesh data providers label Sep 15, 2020
@peetw
Copy link
Author

peetw commented Sep 15, 2020

@rouault is that something that could be changed without breaking other components? Or is this likely to be a larger change (the integer list editor widget sounds fairly fundamental)? Would this issue also affect non-integer (e.g. real/float) lists?

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!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants