-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
QgsVectorLayer from spatialite featureid problem #28453
Comments
Author Name: Giovanni Manghi (@gioman)
|
Author Name: Julien Cabieces (Julien Cabieces) Related to #28367
|
Author Name: Giovanni Manghi (@gioman)
|
Author Name: Henrik Spångmyr (@HenrikSpa) I have some problems with this still both in QGIS 3.4.4 and 3.5.0-master. What works:
What doesn't work:
|
Author Name: Henrik Spångmyr (@HenrikSpa) I have a spatialite database with a table with column obsid. If I try to select these using QgsVectorLayer.selectByIds([1, 2, 3]), only id:s 1 and 2 get's selected. Trying QgsVectorLayer.selectByIds([1, 2, 4]) instead changes nothing. Only id:s 1 and 2 are selected. |
Author Name: Henrik Spångmyr (@HenrikSpa) I have the code:
Gives the result:
So:
|
Author Name: Julien Cabieces (Julien Cabieces) This feature has been backported in 3.4 the 14/01/2019 but the last release (3.4.4) has been done the 18/01/2019, so you have to wait for the next 3.4 release to test this on 3.4. But I can't reproduce any of the problems you're reporting on the current 3.5-master. Did you make the test with a nightly built after the 14/11/2019 ? If not, could you please test with the most recent nightly. I close the issue for now, reopen it if you still encounter the issue on last nightly build
|
Author Name: Henrik Spångmyr (@HenrikSpa) Julien Cabieces wrote:
I can confirm that it works for me also with the latest official 3.5.0 nightly build! (Somehow it didn't work with my own build from the master branch. Not sure what I did wrong.) |
Author Name: Henrik Spångmyr (@HenrikSpa)
Original Redmine Issue: 20633
Affected QGIS version: 3.4.1
Redmine category:data_provider/spatialite
Assignee: Julien Cabieces
There seems to be an issue with QgsVectorLayers when the first column (key column?) contains values other than integers.
It appears that the Feature ID are set from the first column, and when that column contains non-integer values like letters, the Feature ID is set to 0. The result is that when this feature is selected, all features sharing featureid=0 are also selected.
This problem doesn't exist when loading the same table from PostGIS.
It workes fine using QGIS 2.18.24.
Background:
I have a table (same layout in both spatialite and postgis):
@
CREATE TABLE obs_points (
obsid text NOT NULL
, name text
, ...
, ...
, PRIMARY KEY (obsid))
@
Adding geometry for spatialite:
@
SELECT AddGeometryColumn('obs_points', 'geometry', 3006, 'POINT', 'XY', 0);
@
And for postgis:
@
ALTER TABLE obs_points ADD COLUMN geometry geometry(Point,3006);
@
I load this table to qgis using the QGIS "Add Spatialite Layer" and "Add PostGIS Layer".
Adding features in the spatialite layer works fine as long as I only use integers for the obsid column. If I set obsid to letters, "Feature ID" is set to 0. If I set obsid to a float, it gets converted to integer.
Ex:
obsid=1 > Feature ID=1
obsid=2 > Feature ID=2
obsid=A> Feature ID=0
obsid=b> Feature ID=0
obsid=1.5> Feature ID=1
obsid=2.5> Feature ID=2
Selecting obsid=1.5 also selects obsid=1.
I've also tried to load the spatialite layer using the python api and two different uri-strings:
@
uri = QgsDataSourceUri()
layer1 = QgsVectorLayer("""dbname='/path/to/db.sqlite' key='obsid' table="obs_points" (geometry) sql=""", 'obs_points', 'spatialite')
layer2 = QgsVectorLayer("""dbname='/path/to/db.sqlite' table="obs_points" (geometry) sql=""", 'obs_points', 'spatialite')
@
The resulting layer behaves the same way as the one loaded from the QGIS menu.
Linux Mint 19.
QGIS version
3.4.1-Madeira
QGIS code revision
383851c
Compiled against Qt
5.9.5
Running against Qt
5.9.5
Compiled against GDAL/OGR
2.2.3
Running against GDAL/OGR
2.2.3
Compiled against GEOS
3.6.2-CAPI-1.10.2
Running against GEOS
3.6.2-CAPI-1.10.2 4d2925d6
PostgreSQL Client Version
10.3 (Ubuntu 10.3-1)
SpatiaLite Version
4.3.0a
QWT Version
6.1.3
QScintilla2 Version
2.10.2
PROJ.4 Version
493
The text was updated successfully, but these errors were encountered: