[Ur] Explicitly asking for a sql rollback

Simon Van Casteren simon.van.casteren at gmail.com
Sun Feb 3 05:24:27 EST 2019


Hey,

I'm wondering if there is a way to explicitly ask for a sql rollback. I
think the only way you can now trigger a rollback would be by calling the
"error" function and providing an xbody.

I have two use cases for which I think an explicit rollback mechanism (not
sure how that would look like) would be handy. My main use case is rolling
back everything when a validation is not ok. I don't use the "error"
function because I can't return structured error messages. When I save some
form with 5 fields, I mostly return an error object with the same 5 fields,
so I can provide precise feedback to the user. Having to clean up all my
sql work is huge drag and a source of subtle bugs.

My second use case is testing with the database. I know some people frown
upon incorporating the database into your tests, but I think that's silly
so I'll ignore that. If have quite some tests that load stuff into the
database as a setup step, then run some tricky query procedure, check the
results, and then clear the DB again. This last step is again a big
annoyance and a source of incorrectly failing tests.

Does anyone have a good way of doing the 2 above things? Should we have an
explicit "rollback" call? Probably it's quite a dangerous thing to have,
but especially the first described problem is a source of serious bugs,
especially in complex backend procedures.

Any help much appreciated!

Simon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20190203/830b838d/attachment.html>


More information about the Ur mailing list