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.58k stars 3k forks source link

DB Manager displays values in wrong columns for tables without primary key field #57566

Open raymondnijssen opened 5 months ago

raymondnijssen commented 5 months ago

What is the bug or the crash?

When viewing the table content (tab "table") in the DB Manager for a table without a unique primary key field, QGIS fills the values of the first column in the table with an auto enumeration (1,2,3, ...) and shows the values of the first column in the second column and so on. The values of the last column are not shown at all.

I would expect QGIS to not add any values, as they are not present in the table (and this is a table preview). Or, if those values need to be shown anyway, add a "fid" column for it. The latter is done by the QGIS in the "Execute SQL" window.

Steps to reproduce the issue

  1. Download the GeoPackage: https://service.pdok.nl/bzk/bro-bodemkaart/atom/downloads/BRO_DownloadBodemkaart.gpkg
  2. Make a GPKG connection in QGIS Browser
  3. Right click the table "soilcharacteristics_bottomlayer", choose "Execute SQL ..." and run the preset query. The table appears with a generated "fid" column. (This is correct.)
  4. Open DB Manager and select the table "soilcharacteristics_bottomlayer" of the gpkg.
  5. Select the "table" tab for a table preview. The displayed table does show the generated fid values but in the wrong column.

Screenshot from 2024-05-25 11-36-54

The screenshot shows the same table 3 times, once in DB Browser, once in Execute SQL and once in the DB Manager.

Tested in QGIS master and QGIS 3.30 with the same results.

Versions

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

QGIS version | 3.37.0-Master | QGIS code revision | 810a61a791e -- | -- | -- | -- Qt version | 5.15.3 Python version | 3.10.12 GDAL/OGR version | 3.4.1 PROJ version | 8.2.1 EPSG Registry database version | v10.041 (2021-12-03) GEOS version | 3.10.2-CAPI-1.16.0 SQLite version | 3.37.2 PDAL version | 2.3.0 PostgreSQL client version | 14.11 (Ubuntu 14.11-0ubuntu0.22.04.1) SpatiaLite version | 5.0.1 QWT version | 6.1.4 QScintilla2 version | 2.11.6 OS version | Ubuntu 22.04.4 LTS   |   |   |   Active Python plugins db_manager | 0.1.20 grassprovider | 2.12.99 processing | 2.12.99 MetaSearch | 0.3.6 QGIS version 3.37.0-Master QGIS code revision [810a61a791e](https://github.com/qgis/QGIS/commit/810a61a791e) Qt version 5.15.3 Python version 3.10.12 GDAL/OGR version 3.4.1 PROJ version 8.2.1 EPSG Registry database version v10.041 (2021-12-03) GEOS version 3.10.2-CAPI-1.16.0 SQLite version 3.37.2 PDAL version 2.3.0 PostgreSQL client version 14.11 (Ubuntu 14.11-0ubuntu0.22.04.1) SpatiaLite version 5.0.1 QWT version 6.1.4 QScintilla2 version 2.11.6 OS version Ubuntu 22.04.4 LTS Active Python plugins db_manager 0.1.20 grassprovider 2.12.99 processing 2.12.99 MetaSearch 0.3.6 ### Supported QGIS version - [X] I'm running a supported QGIS version according to [the roadmap](https://www.qgis.org/en/site/getinvolved/development/roadmap.html#release-schedule). ### New profile - [X] I tried with a new [QGIS profile](https://docs.qgis.org/latest/en/docs/user_manual/introduction/qgis_configuration.html#working-with-user-profiles) ### Additional context _No response_
raymondnijssen commented 5 months ago

Could somehow be related to this: https://github.com/qgis/QGIS/issues/50509

agiudiceandrea commented 5 months ago

It may also have the same root cause of https://github.com/qgis/QGIS/issues/56616.