QGIS shows default values from sqlite tables as string in the edit-form when i try to create a new row. After save, the raw default values are stored in the table. How can i edit in QGIS LTR 3.4.7 a sqlite-database without messing up the default values from the tables?
QGIS-form with new feature and 'wrong' default-values. Feature from sql-insert with id 1 in background.
QGIS-table after save with pointless default-values.
tried "solutions"
- with "sql-insert" everything works as exepected
- same behaviour on different workstations
- same behaviour for sqlite- and spatialite-databases
- same behaviour with or whitout geometry
- same behaviour in QGIS 3.4.7 (LTR) and 3.10
- same behaviour in Windows and Linux
- same behaviour with default-values in a geopackage
- in spatialite
InvalidateLayerStatistics();
andUpdateLayerStatistics();
does not help. - Project Properties -> Data Source -> Check "Evaluate default values on provider side".
- (maybe) relevant google-search results :
Create statement for the table in the sqlite-database
CREATE TABLE my_table (
id integer primary key autoincrement,
comment text,
created_at_01 text DEFAULT (datetime('now','localtime')),
created_at_02 text DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO my_table (comment) VALUES ('hello world');
SELECT * FROM my_table;
id comment created_at_01 created_at_02
---------- ----------- ------------------- -------------------
1 hello world 2019-12-09 18:00:12 2019-12-09 17:00:12
now()
.0
. Default value in the widget works. But the default definition in the database is prefered for various reasons.