Bug report #10381
Attribute table does not show new columns of spatialite layer
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||duplicate|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||18799|
When adding a column to a spatialite vector layer, using QSpatialite or any other tool, the column does not show in the attribute table. It does show in the dbManager and (obviously) in the QSpatialite.
Absolutely not sure if it has anything to do with this problem, but checking the various system tables in the spatialite db, I noticed that in the table geometry_columns_field_infos only the original columns are included. Perhaps the attribute table only shows the columns referenced in this table?
Using QGIS 2.3.0-Master, QGIS code revision a76ec72 on Ubuntu 13.10
#1 Updated by Giovanni Manghi over 9 years ago
- Affected QGIS version changed from 2.2.0 to master
- Status changed from Open to Feedback
- Category changed from Attribute table to Data Provider/SpatiaLite
Just tested master on Linux. SL DB created in QGIS (master), created a layer in it with 1 column, added a few features. Then in layer properties -> fields added a new column, this shows just fine.
What version are you SL BDs? where you created them? can you attach a sample one?
#2 Updated by pvanbosgeo - over 9 years ago
- File db.sqlite added
Did some testing, and it depends on how the tables are created.
A) if the layer is created by importing shapefile, all works as it should. Columns, whatever way created, show up without problem
B) layers created by copying them from another database (using 'insert into' to copy table from attached database; or in this case I used the data transfer option in Navicat, which uses this method I think). After import, I use 'recover Geometry column to spatially enable the layer again. Now, creating new columns in e.g., QSpatialite do not show up in the attribute table.
It is in fact a bit more complicated:
1) Adding a column (test1) via layer properties works. It shows in the attribute table. However,
2) if I add a column (test2) using the QSpatialite using the ALTER TABLE sql, suddenly both columns test1 and test2 are not shown anymore in the attribute table, nor are the columns visible anymore in the layer properties.
3) If after that I add a new column in layer properties (test3), gives the error message below
Could not commit changes to layer eth_adm0 Errors: SUCCESS: 1 attribute(s) added. ERROR: the count of fields is incorrect after addition/removal of fields!
4) It seems however it did commit the changes anyway. Closing and then opening the layer properties, and all three columns test1, test2 and test3 are there.
Attached a database with three tables.
1) ethiopia: added by importing a shapefile. Added the column test1 using the 'insert into' in QSpatialite
2) ken_adm0: added by copying it from another database using the data transfer option in Navicat. Also here I added the column test1 using the 'insert into' in QSpatialite. The column is there, but it doesn't show in the attribute table or the layer properties
3) tz_adm0: added also by copying from another database. However in this case I did not recover the geometry, so it is not registred as a spatial table.