From aa2da68f6bfc3649fcb43afa1b88909ef278ac60 Mon Sep 17 00:00:00 2001 From: Ziv Scully Date: Mon, 29 Jun 2015 01:33:47 -0700 Subject: Refactored a lot and fixed an and/or swap, but still not good on current test. --- caching-tests/test.ur | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'caching-tests') diff --git a/caching-tests/test.ur b/caching-tests/test.ur index 842fd77d..ba3a337d 100644 --- a/caching-tests/test.ur +++ b/caching-tests/test.ur @@ -11,29 +11,27 @@ fun cache id = | Some row => {[row.Tab.Val]}} + fun flush id = - res <- oneOrNoRows (SELECT tab.Val - FROM tab - WHERE tab.Id = {[id]}); - (case res of - None => return () (* dml (INSERT INTO tab (Id, Val) *) - (* VALUES ({[id]}, 0)) *) - | Some row => dml (UPDATE tab - SET Val = {[row.Tab.Val + 1]} - WHERE Id = {[id + 1]} OR Id = {[id]} (* OR Id = {[id - 1]} *))); + dml (UPDATE tab + SET Val = 42 + WHERE Id = {[id]} OR Id = {[id + 1]}); return - {case res of - None => Initialized {[id]}! - | Some row => Incremented {[id]}!} + Changed {[id]}! -(* task periodic 5 = *) -(* fn () => *) -(* t <- now; *) -(* let *) -(* val n = toSeconds t % 2 *) -(* in *) -(* dml (UPDATE tab *) -(* SET Val = 9001 *) -(* WHERE Id = {[n]} OR Id = {[n+1]}) *) -(* end *) +(* fun flush id = *) +(* res <- oneOrNoRows (SELECT tab.Val *) +(* FROM tab *) +(* WHERE tab.Id = {[id]}); *) +(* (case res of *) +(* None => dml (INSERT INTO tab (Id, Val) *) +(* VALUES ({[id]}, 0)) *) +(* | Some row => dml (UPDATE tab *) +(* SET Val = {[row.Tab.Val + 1]} *) +(* WHERE Id = {[id]} OR Id = {[id + 1]})); *) +(* return *) +(* {case res of *) +(* None => Initialized {[id]}! *) +(* | Some row => Incremented {[id]}!} *) +(* *) -- cgit v1.2.3