[Cubicweb] ValidationError and implicit rollbacks
sylvain.thenault at logilab.fr
Thu Sep 30 17:15:57 CEST 2010
On 30 septembre 17:04, Aurélien Campeas wrote:
> > > am i missing something ?
> > this has been introduced because currently, it may occur that a ValidationError
> > is raised but the value has been saved in the database. The repository should
> > not let a subsequent commit commiting the database with some integrity error
> > inside.
> "user" code catching ValidationError do so with full responsibility; I
> don't believe the _querier_ has a say in it
The repository is responsible to ensure data integrity.
> > We already had such behaviour in case where Unauthorized is raised. It's now
> > documented that it also happen on ValidationError. We also already had such
> > mecanism in case of error during commit.
> > The other possibility is to do like regular DBMS does: no rollback is done,
> > but the connection is left in a state where you can't do anything with it
> > until you rollback. I don't think that would make anything better though.
> regular DBMSes, fortunately, provide means to tell to defer constraint
> checking with DEFERRED/DEFERRABLE stuff so as to allow a temporary
> inconsistent state (when they do not provide this, it is a real PITA and
> must be worked around as was recently discovered with sql server and
> unique constraints)
> the db MUST be consistent by the end of the transaction but there can be
> no garantee before that
That's the point. Currently, we can commit a transaction with inconsistent data.
Notice I'm not particularly happy with the current solution, though I don't feel
the repository should let user code commit inconsistent data except when explicitly
asked (eg by deactivating integrity hook).
Another solution, that would at least suits your need, would be to flag the connection
so that no commit will be possible.
Sylvain Thénault LOGILAB, Paris (France)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure: http://www.logilab.fr/services
CubicWeb, the semantic web framework: http://www.cubicweb.org
More information about the Cubicweb