<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Nov 20, 2017 at 3:51 PM, Matthias Kuhn <span dir="ltr"><<a href="mailto:matthias@opengis.ch" target="_blank">matthias@opengis.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<p>Hi Alessandro,</p>
<p>This problem also applies to editing multiple layers in parallel
(especially with foreign keys), that was one of the drivers to
introduce transaction editing.</p>
<p>For individual layers, I think we can keep track of all the
changes in the local edit buffer. For issue 16935, I think the
order wouldn't actually change much, it would still fail, just in
a different order? </p></div></blockquote><div><br></div><div>Yes, but without data corruption. That is what we need to fix with higher priority, if the operation fails without crippling the data I think it would be acceptable, but if it fails with data loss that is not acceptable.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF"><p>One thing there is, the commands could be sent
in a single transaction (which doesn't necessarily need to be
managed by QgsTransaction).</p></div></blockquote><div> </div><div>I don't understand this part: QgsTransaction looks like the right class to handle transactions, I think it should be used to wrap the whole commitChanges for providers that support the transactions.<br></div><div></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF">
<p>On the other hand, I think splitFeature should be using
QgsVectorLayer.createFeature() which should take care of unique
constraints detected on the provider. If I'm not mistaken, this
works fine on postgres, possibly there's an issue with unique
constraint detection in sqlite based providers?</p></div></blockquote><div><br></div><div>It is using that class ...</div><div><br></div><div>Thanks! I'll look into that method, it looks like a good lead.<br></div><div><br></div><div></div><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div bgcolor="#FFFFFF">
<p>Cheers</p>
<p>Matthias<br>
</p><div><div class="gmail-h5">
<br>
<div class="gmail-m_-4562648931972425094moz-cite-prefix">On 11/20/2017 01:02 PM, Alessandro
Pasotti wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="gmail-h5">
<div dir="ltr">
<div>
<div>Hi,<br>
<br>
</div>
I'm facing a bug [1] that led me to a potential issue in the
editing buffer implementation: when commitChanges is called,
different operations (change geometry, change attrs, add
features, delete features ...) are grouped and executed in a
fixed order.<br>
<br>
</div>
So, if I wanted for example insert a feature and (after the
insert has been successful)<br>
<div>change the geometry of another feature I cannot do that
because all geometry editing operations are grouped and
executed before all the insert feature operations are executed
[2]<br>
</div>
<div><br>
</div>
<div>This issue can lead to data loss in several scenarios, one
is the bug I'm working on here but there are more: for example
when you want to merge features you cannot delete features
after you have successfully created the merged one, just
because all delete operations are performed before the insert
ones.</div>
<div><br>
</div>
<div>I guess that by grouping related commands together we
probably wanted to make it easier to optimize the operations
in the back-end.<br>
</div>
<div><br>
</div>
<div>Wrapping the commitChanges into transactions would help
with DB-like backends that support it (I think that the
implementation is not yet completed), but I'm still convinced
that the order of edit commands within an editing buffer
should be respected (that does not mean that certain commands
cannot be grouped if the programmer choose to do so).</div>
<div><br>
</div>
<div>I'd like to hear your opinion about the possible solutions
to this problem.<br>
</div>
<div><br>
<br>
[1] <a href="https://issues.qgis.org/issues/16935" target="_blank">https://issues.qgis.org/<wbr>issues/16935</a></div>
<div>[2] <a href="https://github.com/qgis/QGIS/blob/master/src/core/qgsvectorlayereditbuffer.cpp#L300" target="_blank">https://github.com/qgis/QGIS/<wbr>blob/master/src/core/<wbr>qgsvectorlayereditbuffer.cpp#<wbr>L300</a></div>
<div><br clear="all">
<div>
<div><br>
-- <br>
<div class="gmail-m_-4562648931972425094gmail_signature">Alessandro Pasotti<br>
w3: <a href="http://www.itopen.it" target="_blank">www.itopen.it</a></div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="gmail-m_-4562648931972425094mimeAttachmentHeader"></fieldset>
<br>
</div></div><pre>______________________________<wbr>_________________
QGIS-Developer mailing list
<a class="gmail-m_-4562648931972425094moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="gmail-m_-4562648931972425094moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a>
Unsubscribe: <a class="gmail-m_-4562648931972425094moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a></pre>
</blockquote>
<br>
</div>
<br>______________________________<wbr>_________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Alessandro Pasotti<br>w3: <a href="http://www.itopen.it" target="_blank">www.itopen.it</a></div>
</div></div>