-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Weird QGIS behaviour when modifying a spatialite table #27425
Comments
Author Name: Christophe Damour (@sigeal) Also reproduced on Ubuntu 16.04 |
Author Name: Giovanni Manghi (@gioman)
|
Author Name: Giovanni Manghi (@gioman) Please try on QGIS 3.4.1, if the issue is still valid change the affected version, thanks.
|
Author Name: Christophe Damour (@sigeal) Problem still there in 3.4.1, but I can't modify the affected version... |
Author Name: Giovanni Manghi (@gioman)
|
Author Name: Julien Cabieces (Julien Cabieces) It seems to be a problem in spatialite. I create a ticket : https://www.gaia-gis.it/fossil/libspatialite/tktview/e8d83559fbc5d492ff1dff86e07751547b485430
|
Author Name: Giovanni Manghi (@gioman) Julien Cabieces wrote:
should this be confirmed as a SL issue this ticket must be closed as "upstream". |
Author Name: Mark Johnson (Mark Johnson) This is a user error, not a spatialite error.As a general rule, the following should be considered true:
In this case the old SpatialTable was renamed using
The (closed) Spatialite Issue contains tips on how to deal with this correctly, using spatialite commands that deals with administration TABLEs properly. |
Author Name: Julien Cabieces (Julien Cabieces) Thank you for the detailed answer and sorry for the useless spatialite ticket. There is still a bug in QGIS because renaming a table is done wrong in db manager plugin (alter table instead of rename table). I close this issue because there is already another one on the subject #22236
|
Author Name: Christophe Damour (@sigeal) Thank you all for input on this problem. |
Author Name: Christophe Damour (@sigeal) Attempt to summarize what currently works in QGIS 3.4.1 using DB Manager Plugin (special thanks to Mark Johnson for the guidelines) :
Note : DropGeoTable should be replaced by DropTable when SpatiaLite lib will be updated in QGIS. |
Author Name: Mark Johnson (Mark Johnson) Add the following to round it off:
|
Author Name: Mark Johnson (Mark Johnson) For future reference:
These commands will insure that all administration tasks will be completed correctly including the renaming/adapting of all TRIGGERs and VIEWs, for both 'Normal' and SpatialTables. Preparations are in the last testing phase for support for GeoPackages and Gdal/Ogr-Fdo Databases. Due to the historical development of SQLite, care must be taken to create VIEWs with proper field definitions (which are optional). Full details and background information can be found here: |
Author Name: Christophe Damour (@sigeal)
Original Redmine Issue: 19598
Affected QGIS version: 3.4.1
Redmine category:attribute_table
Assignee: Julien Cabieces
I am trying to modify column names in a SpatiaLite table.
To do that, I run the following SQL statements in the DB Manager :
-- Rename existing table
ALTER TABLE compteur_routier RENAME TO compteur_routier_sav;
-- Create new table with modified column names
CREATE TABLE compteur_routier (
id INTEGER PRIMARY KEY,
geom POINT,
id_compt TEXT,
type_compt TEXT,
angle INTEGER,
id_tmp INTEGER
);
-- Insert data from renamed table
INSERT INTO compteur_routier(id, geom, id_compt, type_compt, angle, id_tmp)
SELECT id, geom, id_compteur, type_compteur, angle, id_tmp FROM compteur_routier_sav;
-- Drop renamed table
DROP TABLE compteur_routier_sav;
This works perfectly in the DB manager, column names are modified and datas are kept.
However, when I load the resulting table in QGIS and open the attribute table, I get old column names and datas replaced by column names.
Please have a look at screenshots and test db in attached files.
The text was updated successfully, but these errors were encountered: