Bug report #8636
spatialite provider error when primary key is made from multiple integer columns
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||17368|
Adding new features to a spatialite layer fails when the layer has a primary key made from more than one column and at least one of them is of integer type. The following commit error is shown:
SQLite error: t2.col_2 may not be NULL
SQL: INSERT INTO "t2"("col_1","col_2") VALUES (?,?)
The bug seems to be related to use of QVariant::LongLong as int type in the spatialite data provider, revision 2f2e0880.
To reproduce the problem. Download attached sample data and project, start editing session for any of the layers t2, t5 or t6 and notice how adding features will fail.
[spatialite] Several fixes for provider (Fix #8636)
And fixes the NoGeometry behavior
#2 Updated by Josef Källgården about 6 years ago
- File test_18.zip added
Yes it is a regression since 1.8, see attached db which contains one table - features can be added in qgis 1.8 but neither with 2.0 nor master.
It does happen on both 2.0 and master (I only found 'master' in the list for affected version).
#4 Updated by Bertrand Roux almost 6 years ago
I have the same issue but on all integer fields.
I create a simple table with an integer autoincremented field as primary key ("pkfield"), a value field of type integer ("val") and a geometry field (POINT for example). In QGis, when I had a new feature to this layer, I put a value in the value field "val" (for example 1). When I open the attribute table, this value appears. But when I do the commit on the layer, the value is not send to the spatialite database : the feature is created without value in field "val" (no error is raised in QGis).
The strange point is when I update the value field "val" on an existing feature in QGis, the integer value is transmitted to the database on commit...