Bug report #21447

Vectorlayer from spatialite missing features and inconsistent feature count

Added by Henrik Spångmyr over 5 years ago. Updated over 5 years ago.

Status:Feedback
Priority:Normal
Assignee:-
Category:Data Provider/SpatiaLite
Affected QGIS version:3.6.0 Regression?:No
Operating System:Linux Mint 19.1 Tessa Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:29264

Description

QGIS show different feature count in layer list and in attribute table and some features are missing in attribute table.

I have database A with 1622 features in table obs_points.
I have a view of table obs_points, also with 1622 features.

I created a new database B and transfered all rows from A.obs_points to B.obs_points. Database B also has a view of B.obs_points.

I've attached an image which shows the issue.

There should be 1622 rows in all tables and views.

Layer obs_points_A show 1480 features in the layerlist, but 1580 in the attribute table and 1622 in spatialite_gui. << WRONG
Layer obs_points_A_view show 1565 features in the layerlist, but 1622 in the attribute table and 1622 in spatialite_gui. << WRONG
Layer obs_points_B show 1622 features in the layerlist, but 1622 in the attribute table and 1622 in spatialite_gui. << Correct
Layer obs_points_B_view show 1622 features in the layerlist, but 1622 in the attribute table and 1622 in spatialite_gui. << Correct

When I look in the attribute table for obs_points_A, the rows with rowids 1-42 (the rowid in the sqlite table) seems to be the missing rows.

Also, loading a spatialite table to QgsVectorLayer using qgis, i get vlayer.featureCount()=0 for some reason while I get lots of features from vlayer.getFeatures(). Not sure if it's related or not.

So, my transfer of rows fixed the issue, but I'm not sure why the first database isn't working well with QGIS 3.6.

featurecount_bug.png (180 KB) Henrik Spångmyr, 2019-03-02 10:35 AM

qgis_redmine_21447_2.sqlite (236 KB) Henrik Spångmyr, 2019-03-02 12:57 PM

History

#1 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Open to Feedback

Can you please attach sample data? thanks!

#2 Updated by Henrik Spångmyr over 5 years ago

  • File qgis_redmine_21447_.sqlite added
  • Status changed from Feedback to Open

I've attached a database that originally was database "A" as described in the bug report.

I
... removed all tables except obs_points and view_obs_points.
... set all columns to NULL except the column obs_points.obsid. I've also renamed all obsids to the same as ROWID.
... cleared sql_statements_log.

I've found the 1480 number in this sql-query:
SELECT ROWID, "f_table_name", "f_geometry_column", "last_verified", "row_count" FROM "geometry_columns_statistics":
4 obs_points geometry 2018-01-31T14:27:43.790Z 1480

#3 Updated by Henrik Spångmyr over 5 years ago

I've attached a new file to replace the first.

#4 Updated by Giovanni Manghi over 5 years ago

  • File deleted (qgis_redmine_21447_.sqlite)

#5 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Open to Feedback

The attached sample, should represent the database A or B?

Here on master (ubuntu) in the dataset you attached I see 1622 records in both the table and the view.

#6 Updated by Giovanni Manghi over 5 years ago

Henrik Spångmyr wrote:

I've attached a database that originally was database "A" as described in the bug report.

ok I overlooked this... so this means the atatched database is "A", this also means I can't confirm the issue.

#7 Updated by Henrik Spångmyr over 5 years ago

Giovanni Manghi wrote:

Henrik Spångmyr wrote:

I've attached a database that originally was database "A" as described in the bug report.

ok I overlooked this... so this means the atatched database is "A", this also means I can't confirm the issue.

How odd!

I've downloaded my uploaded file, loading the tables obs_points and view_obs_points using Layer>Add Layer>Add SpatiaLite Layer.
If I right-click and mark "Show Feature Count" in for both layers, obs_points show [1480] and view_obs_points show [1565].
The attribute table still show 1580 features for obs_points.

This is with the release QGIS version 3.6.0-Noosa QGIS code revision 5873452.

Maybe there is a fix in the master that isn't in the 3.6 release?

#8 Updated by Henrik Spångmyr over 5 years ago

I've reinstall QGIS to QGIS version 3.7.0-Master QGIS code revision 83f286a

I still get the same feature counts both in the Layer window and the attribute table.

So maybe there is something else going on here. Like the spatialite version. I have SpatiaLite Version 4.3.0a.

#9 Updated by Giovanni Manghi over 5 years ago

So maybe there is something else going on here. Like the spatialite version. I have SpatiaLite Version 4.3.0a.

same version here.

Try with a new/clean profile.

#10 Updated by Giovanni Manghi over 5 years ago

Try with a new/clean profile.

no 3rd party plugins

#11 Updated by Henrik Spångmyr over 5 years ago

Giovanni Manghi wrote:

Try with a new/clean profile.

no 3rd party plugins

I reinstall QGIS 3.6 release, but I also have an own built version QGIS-version 3.7.0-Master QGIS kodrevision b1e280b3e8

I created new profiles for both of them. There are no 3rd party plugins activated in the profiles.

I still get the same feature counts in both layerlist and attribute table for both versions.

I will build a version from the github master and check that also.

#12 Updated by Henrik Spångmyr over 5 years ago

  • Status changed from Feedback to Open

I've installed my fresh build from github master branch:

QGIS-version 3.7.0-Master QGIS kodrevision 55732128f7

I've created a new profile.

Still the same feature counts.

#13 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Open to Feedback

Henrik Spångmyr wrote:

I've installed my fresh build from github master branch:

QGIS-version 3.7.0-Master QGIS kodrevision 55732128f7

I've created a new profile.

Still the same feature counts.

and... still can't confirm here, tried also in my clean testing Windows environment (QGIS master, 3.6).
This will need some further investigation on your side as it seems a local issue anyway.

Have you tried on a completely different box (or even a VM)?

#14 Updated by Henrik Spångmyr over 5 years ago

Now I've tested some more.

Main system QGIS 3.6, 3.7 nightly > The problem in the bug report.
QGIS 2.18 on virtualbox -> Works. 1622 features on all places.
QGIS 3.4.x on other virtualbox > Same problem as the bug report.
QGIS 3.6.0 on windows 10 (not virtualbox) > Same problem as bug report! (see specifics below).

So the issue exists for me on 3 different installations, two linux mint 19.1 and one windows 10, all running qgis3 and two running qgis 3.6!

The Windows10 version:
QGIS-version
3.6.0-Noosa
QGIS kodrevision
58734527ab
Kompilerad för Qt
5.11.2
Kör med Qt
5.11.2
Kompilerad mot GDAL/OGR
2.4.0
Körs mot GDAL/OGR
2.4.0
Kompilerad mot GEOS
3.7.0-CAPI-1.11.0
Kör mot GEOS
3.7.0-CAPI-1.11.0 673b9939
PostgreSQL-klientversion
9.2.4
SpatiaLite-version
4.3.0
QWT-version
6.1.3
QScintilla2-version
2.10.8
Kompilerad mot PROJ
520
Kör mot PROJ
5.2.0

#15 Updated by Giovanni Manghi over 5 years ago

Henrik Spångmyr wrote:

Now I've tested some more.

Main system QGIS 3.6, 3.7 nightly > The problem in the bug report.
QGIS 2.18 on virtualbox -> Works. 1622 features on all places.
QGIS 3.4.x on other virtualbox > Same problem as the bug report.
QGIS 3.6.0 on windows 10 (not virtualbox) > Same problem as bug report! (see specifics below).

weird, cannot replicate on both Windows and Linux.

#16 Updated by Henrik Spångmyr over 5 years ago

I've replicated this bug on a second computer with a completely fresh install of Windows 10 with fresh install of QGIS 3.6 using OSGEO4W 64-bit install (http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe).

Also available in: Atom PDF