Mercurial > urweb
comparison caching-tests/test.ur @ 2275:ce96e166d938
Fix some table renaming issues.
author | Ziv Scully <ziv@mit.edu> |
---|---|
date | Sat, 07 Nov 2015 15:16:44 -0500 |
parents | a3cac6cea625 |
children | c05f9a5e0f0f |
comparison
equal
deleted
inserted
replaced
2274:0730e217fc9c | 2275:ce96e166d938 |
---|---|
1 table tab : {Id : int, Val : int} PRIMARY KEY Id | 1 table tab : {Id : int, Val : int, Foo : int} PRIMARY KEY Id |
2 | 2 |
3 fun cache id = | 3 fun cache id = |
4 res <- oneOrNoRows (SELECT tab.Val | 4 res <- oneOrNoRows (SELECT tab.Val |
5 FROM tab | 5 FROM tab |
6 WHERE tab.Id = {[id]}); | 6 WHERE tab.Id = {[id]}); |
20 (* {case res of *) | 20 (* {case res of *) |
21 (* None => <xml>Nope, that's not it.</xml> *) | 21 (* None => <xml>Nope, that's not it.</xml> *) |
22 (* | Some _ => <xml>Hooray! You guessed it!</xml>} *) | 22 (* | Some _ => <xml>Hooray! You guessed it!</xml>} *) |
23 (* </body></xml> *) | 23 (* </body></xml> *) |
24 | 24 |
25 fun cache2 id1 id2 = | 25 (* fun cache2 id1 id2 = *) |
26 res1 <- oneOrNoRows (SELECT tab.Val | 26 (* res1 <- oneOrNoRows (SELECT tab.Val *) |
27 FROM tab | 27 (* FROM tab *) |
28 WHERE tab.Id = {[id1]}); | 28 (* WHERE tab.Id = {[id1]}); *) |
29 res2 <- oneOrNoRows (SELECT tab.Val | 29 (* res2 <- oneOrNoRows (SELECT tab.Val *) |
30 FROM tab | 30 (* FROM tab *) |
31 WHERE tab.Id = {[id2]}); | 31 (* WHERE tab.Id = {[id2]}); *) |
32 return <xml><body> | 32 (* return <xml><body> *) |
33 Reading {[id1]} and {[id2]}. | 33 (* Reading {[id1]} and {[id2]}. *) |
34 {case (res1, res2) of | 34 (* {case (res1, res2) of *) |
35 (Some _, Some _) => <xml>Both are there.</xml> | 35 (* (Some _, Some _) => <xml>Both are there.</xml> *) |
36 | _ => <xml>One of them is missing.</xml>} | 36 (* | _ => <xml>One of them is missing.</xml>} *) |
37 </body></xml> | 37 (* </body></xml> *) |
38 | 38 |
39 fun flush id = | 39 fun flush id = |
40 dml (UPDATE tab | 40 dml (UPDATE tab |
41 SET Val = Val * (Id + 2) / Val - 3 | 41 SET Val = Val * (Id + 2) / Val - 3 |
42 WHERE Id = {[id]} OR Id = {[id - 1]} OR Id = {[id + 1]}); | 42 WHERE Id = {[id]} OR Id = {[id - 1]} OR Id = {[id + 1]}); |
43 return <xml><body> | 43 return <xml><body> |
44 Changed {[id]}! | 44 Changed {[id]}! |
45 </body></xml> | 45 </body></xml> |
46 | 46 |
47 val flush17 = | 47 fun flash id = |
48 dml (UPDATE tab | 48 dml (UPDATE tab |
49 SET Val = Val * (Id + 2) / Val - 3 | 49 SET Foo = Val |
50 WHERE Id = 17); | 50 WHERE Id = {[id]} OR Id = {[id - 1]} OR Id = {[id + 1]}); |
51 return <xml><body> | 51 return <xml><body> |
52 Changed specifically 17! | 52 Maybe changed {[id]}? |
53 </body></xml> | 53 </body></xml> |
54 | |
55 fun floosh id = | |
56 dml (UPDATE tab | |
57 SET Id = {[id + 1]} | |
58 WHERE Id = {[id]}); | |
59 return <xml><body> | |
60 Shifted {[id]}! | |
61 </body></xml> | |
62 | |
63 (* val flush17 = *) | |
64 (* dml (UPDATE tab *) | |
65 (* SET Val = Val * (Id + 2) / Val - 3 *) | |
66 (* WHERE Id = 17); *) | |
67 (* return <xml><body> *) | |
68 (* Changed specifically 17! *) | |
69 (* </body></xml> *) | |
54 | 70 |
55 (* fun flush id = *) | 71 (* fun flush id = *) |
56 (* res <- oneOrNoRows (SELECT tab.Val *) | 72 (* res <- oneOrNoRows (SELECT tab.Val *) |
57 (* FROM tab *) | 73 (* FROM tab *) |
58 (* WHERE tab.Id = {[id]}); *) | 74 (* WHERE tab.Id = {[id]}); *) |