Bug report #13482

only first element selectable in spatialite layer

Added by Jochen Huber over 5 years ago. Updated over 2 years ago.

Category:Data Provider/SpatiaLite
Affected QGIS version:master Regression?:No
Operating System:Windows (OSGeo4W64) Easy fix?:No
Pull Request or Patch supplied:No Resolution:end of life
Crashes QGIS or corrupts data:No Copied to github as #:21527


When using the "select single feature" tool to select features from a spatialite layer (testet with multiline, line, point and polygon), the feature which was the first to be added to the dataset is highlighted and selected regardless of the feature which is clicked. Thus only this feature can be selected interactively. Selection from the attribute table works for all features.
An example DB and project file are attached.
When exporting a dataset to shapefile and loading the shapoefile in QGIS, selection works as expected, so this seems to be a spatialite-specific problem.

example.qgs - example project file (36 KB) Jochen Huber, 2015-10-01 07:19 AM

myDB.sqlite - db with data (4.22 MB) Jochen Huber, 2015-10-01 07:19 AM

Related issues

Related to QGIS Application - Bug report #14233: Spatialite view, identify results, view feature form show... Closed 2016-02-04


#1 Updated by Jochen Huber over 5 years ago

Bug report #13437 (Mismatched selection on a query based spatialite layer on 2.10 64bit) describes the same problem for layers based on queries. In the cases I tested it occured also when linking tables directly.

#2 Updated by Jochen Huber over 5 years ago

The cause seems to be that QGIS requires Spatialite layers to have a numeric primary key field. If there is no primary key, all features are shown, but selection always picks the first element as described. If there is a primary key on a non-numeric field (text), features can be added but are not shown afterwards. Probably this is why in the case of bug report #13437 table layers work (because they have a suitable primary key) and query-based layers do not.
We often have datasets where text ids identify individual datasets (eg unique names of wells), so it would be good if qgis could use pkeys based on non-numeric fields.
If there is no easy solution, it would be good if qgis reported a warning when a spatialite layer (tabel- or query-based) is added and it does not find a suitable id field instead of behaving in unexpected ways.

#3 Updated by Grga Franges over 5 years ago

I also notice this behavior on spatialite database created by "Offline editing" tool. I have to note that the ID is numeric there (type is stated as qlonglong and type name as integer). I would also like to note that this was working ok in 2.8 and prior versions - problem first apeared with 2.10.

#4 Updated by Giovanni Manghi about 4 years ago

  • Regression? set to No
  • Easy fix? set to No

#5 Updated by Giovanni Manghi over 2 years ago

  • Resolution set to end of life
  • Status changed from Open to Closed

Also available in: Atom PDF