<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Alessandro,</p>
<div class="moz-cite-prefix">On 2/25/20 5:49 PM, Alessandro Pasotti
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAL5Q671odhkG0XEpBVTS3mWZXX5AVqB-ZXq+E72_dbi-W3ajVw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>Hi,</div>
<div><br>
</div>
<div>it's probably me not being a power user, but from a few
simple tests I'm doing with relations (1:n) on spatialite/gpkg
layers I'm experiencing a few issues and I wonder if there is
something I missed or if we can improve the workflow.</div>
<div><br>
</div>
<div>My test schema is pretty simple:</div>
<div>-----------</div>
<div>table1 (parent)<br>
</div>
<div>-----------<br>
</div>
<div>fid (default: sqlite_fetch_and_increment...)</div>
<div>name</div>
<div><br>
</div>
<div>
<div>-----------</div>
<div>table2 (child)<br>
</div>
<div>-----------<br>
</div>
<div>fid</div>
<div>fk_table1 -> table1.fid<br>
</div>
<div>name</div>
<div><br>
</div>
</div>
<div>ISSUE 1:</div>
<div>- add a new item in table1</div>
<div>- in the embedded form add a table2 item</div>
<div>- click on "Save child layer edits" button -> backend
CONSTRAINT FAILURE! because table1 parent is not saved (and
not even in the editing buffer, for what matters)</div>
</div>
</blockquote>
<blockquote type="cite"
cite="mid:CAL5Q671odhkG0XEpBVTS3mWZXX5AVqB-ZXq+E72_dbi-W3ajVw@mail.gmail.com">
<div dir="ltr">
<div><br>
</div>
<div>QUESTIONS on ISSUE1:</div>
<div>- should we disable the "Save child layer edits" button in
case the parent is unsaved?</div>
<div>- what's the idea behind the "Save child layer edits" when
the user cannot even save the parent from the form, why can
she save the children?</div>
<div>- would it make sense to check for the unsaved parent in
QgsRelationEditorWidget::saveEdits() before attempting a
children save?</div>
</div>
</blockquote>
<p>It works under some given pre-conditions:</p>
<p>- Working with non database systems (shp, xls, ..., risk of data
inconsistencies)<br>
</p>
<p>- Working with database systems without fk constraints (risk of
data inconsistencies)</p>
<p>- Working with databases with transaction mode enabled and
deferred fk checks (<-- it was designed for this exact use
case)</p>
<p><br>
</p>
<p>I'm not sure how to best improve the situation here and help
users to prepare their system apart from documentation. Ideas
welcome.<br>
</p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:CAL5Q671odhkG0XEpBVTS3mWZXX5AVqB-ZXq+E72_dbi-W3ajVw@mail.gmail.com">
<div dir="ltr"><br>
<div>ISSUE 2:</div>
<div>- preparation: add one parent and a few children and commit</div>
<div>- activate identify tool and click on a parent feature<br>
</div>
<div>- the form opens but no children are shown in the child
form, all values are NULL, I would expect that the first child
is automatically selected and focused<br>
</div>
</div>
</blockquote>
<p>Agreed, annoying!<br>
</p>
<blockquote type="cite"
cite="mid:CAL5Q671odhkG0XEpBVTS3mWZXX5AVqB-ZXq+E72_dbi-W3ajVw@mail.gmail.com">
<div dir="ltr">
<div><br>
</div>
<div>ISSUE 3:</div>
<div>
<div>- preparation: add one parent and a few children and
commit</div>
<div>- activate identify tool and click on a parent feature<br>
</div>
</div>
<div>- click on "Add Point child feature"</div>
<div>- click on map canvas</div>
<div>- another attribute form opens, I would expect that instead
of opening a new form, the embedded form was focused, with the
new feature geometry associated and ready for input of other
field values, the form open may be fixed with the option I've
added here: <a
href="https://github.com/qgis/QGIS/pull/34654"
moz-do-not-send="true">https://github.com/qgis/QGIS/pull/34654</a>.</div>
</div>
</blockquote>
<p>That's likely a tricky thing to accomplish with transaction mode
enabled because to bring it into the embedded form it has first to
be sent to the DB and NOT NULL (and other) constraints satisfied
which is hard to guarantee before opening a form.<br>
</p>
<blockquote type="cite"
cite="mid:CAL5Q671odhkG0XEpBVTS3mWZXX5AVqB-ZXq+E72_dbi-W3ajVw@mail.gmail.com">
<div dir="ltr">
<div><br>
</div>
<div>Before I attempt any further patches, I'd like to hear your
opinion on how we could make the data entry process a little
bit easier and error-proof in case of parent-child relations,
especially now that QGIS is dropping the GIS and becoming the
new Access ;)<br>
</div>
</div>
</blockquote>
<p>I think the easiest solution would be to just drop all foreign
keys and other constraints on production databases, they just tend
to mess up things ;P</p>
<p>Matthias<br>
</p>
<p><br>
</p>
<blockquote type="cite"
cite="mid:CAL5Q671odhkG0XEpBVTS3mWZXX5AVqB-ZXq+E72_dbi-W3ajVw@mail.gmail.com">
<div dir="ltr">
<div><br>
</div>
<div>Cheers</div>
<div><br>
</div>
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">Alessandro Pasotti<br>
w3: <a href="http://www.itopen.it" target="_blank"
moz-do-not-send="true">www.itopen.it</a></div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></pre>
</blockquote>
</body>
</html>