https://issues.qgis.org/https://issues.qgis.org/favicon.ico2011-12-16T13:09:33ZQGIS Issue TrackingQGIS Application - Bug report #4569: Primary keys of type TEXT always null after creating feature in spatialite layerhttps://issues.qgis.org/issues/4569?journal_id=275932011-12-16T13:09:33ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Target version</strong> set to <i>Version 1.7.4</i></li></ul> QGIS Application - Bug report #4569: Primary keys of type TEXT always null after creating feature in spatialite layerhttps://issues.qgis.org/issues/4569?journal_id=311472012-04-16T04:32:11ZPaolo Cavallinicavallini@faunalia.it
<ul><li><strong>Crashes QGIS or corrupts data</strong> set to <i>No</i></li><li><strong>Target version</strong> changed from <i>Version 1.7.4</i> to <i>Version 1.8.0</i></li><li><strong>Affected QGIS version</strong> set to <i>master</i></li></ul> QGIS Application - Bug report #4569: Primary keys of type TEXT always null after creating feature in spatialite layerhttps://issues.qgis.org/issues/4569?journal_id=331622012-07-04T05:37:06ZJürgen Fischerjef@norbit.de
<ul><li><strong>Assignee</strong> set to <i>Jürgen Fischer</i></li></ul> QGIS Application - Bug report #4569: Primary keys of type TEXT always null after creating feature in spatialite layerhttps://issues.qgis.org/issues/4569?journal_id=331642012-07-04T06:10:54ZSandro Furieria.furieri@lqt.it
<ul></ul><p>The SpatiaLite data provider always assumes a<br />Primary Key of the INTEGER AUTOINCREMENT type.</p>
<p>please note: the AUTOINCREMENT clause "magically" <br />transforms any NULL value into some unique numeric <br />value not yet used as a key-value, thus effectively<br />hiding any related complexity.<br />the same behaviour isn't obviously possible to <br />support when the Primary Key is of the TEXT type.</p>
<p>I hope this will help to understand why using any <br />Primary Key not defined as INTEGER AUTOINCREMENT<br />isn't a good idea.<br />(and AFAIK, the same is for PostGIS)</p>
<p>bye Sandro</p> QGIS Application - Bug report #4569: Primary keys of type TEXT always null after creating feature in spatialite layerhttps://issues.qgis.org/issues/4569?journal_id=331712012-07-04T11:32:45ZGoyo Dgoyodiaz@gmail.com
<ul></ul><p>Thsnks, Sandro. The problem is that this enforces artificial restrictions on the database schema. I'm happy so far using autoincrement primary keys but I can think of some contexts where it can be an issue.<br />Anyway if this behavoir is a strong design decision feel free to close the ticket as wontfix.</p> QGIS Application - Bug report #4569: Primary keys of type TEXT always null after creating feature in spatialite layerhttps://issues.qgis.org/issues/4569?journal_id=331722012-07-04T12:35:54ZJürgen Fischerjef@norbit.de
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Fixed in changeset <a class="changeset" href="https://issues.qgis.org/projects/qgis/repository/revisions/72d7a238b76c2d9a137da7a7eebe9d7833509561" title="spatialite provider: - fix #4569 - select newly added spatialite database">72d7a238b76c2d9a137da7a7eebe9d7833509561</a>.</p> QGIS Application - Bug report #4569: Primary keys of type TEXT always null after creating feature in spatialite layerhttps://issues.qgis.org/issues/4569?journal_id=331732012-07-04T12:48:25ZJürgen Fischerjef@norbit.de
<ul></ul><p>Jürgen Fischer wrote:</p>
<blockquote>
<p>Fixed in changeset <a class="changeset" href="https://issues.qgis.org/projects/qgis/repository/revisions/72d7a238b76c2d9a137da7a7eebe9d7833509561" title="spatialite provider: - fix #4569 - select newly added spatialite database">72d7a238b76c2d9a137da7a7eebe9d7833509561</a>.</p>
</blockquote>
<p>The value of the primary key still defaults to <code>NULL</code> unless the user changes it. The provider used to overwrite the primary key with NULL, even if the user decided to enter a different value.</p>
<p>Accidental changes could still be avoided by manually setting the edit widget of the field to "Hidden" or "Immutable".</p>
<p>BTW the postgres provider presets the value with the default expression (eg. <code>nextval('table_id_seq')</code>). So the user has a similar option to change that or leave it as is.</p>