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

On 2 April 2010 at 08:28 Danny Groenewegen commented:

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.


On 25 May 2010 at 17:53 Danny Groenewegen closed this issue.

On 25 May 2010 at 17:53 Danny Groenewegen commented:

automatic flush before query enabled in revision 3938

Log in to post comments