Track database modifications and queries to synchronize in between
Try something along the following lines, starting with an empty table X: var x := X { }; x.save(); var list := from X;
What is the length of the list? Intuitively this should be 1. But it is 0. Also, with a non-empty table X:
var x := from X; for( i : X in x ) { i.delete(); } var list := from X;
What is the length of the list? Intuitively this should be 0. But it is equal to the length of x.
This shows a problem in the implementation that makes using .save() and .delete() very counter-intuitive. Indeed, it can introduce nasty situations, where you need to do something the moment you deleted the last one or when you only need to do something if something was just introduced. Instead of just checking you now have to hack around it.
This issue can be resolved as follows: internally track which tables have been touched by updates, mark them dirty, and whenever a table is about to be consulted that was marked dirty, force a flush of all outstanding changes before proceeding.
Submitted by Thomas Schaap on 1 April 2010 at 19:44
Issue Log
We plan to add a flush of the transaction before each query to address this issue. As a workaround, you can call the global
flush()
function yourself.
automatic flush before query enabled in revision 3938
Log in to post comments