comparison tests/tags.ur @ 2032:884673e5f7d5

Finish example
author Adam Chlipala <adam@chlipala.net>
date Wed, 25 Jun 2014 14:19:58 -0400
parents d11a7a9c4a73
children
comparison
equal deleted inserted replaced
2031:d11a7a9c4a73 2032:884673e5f7d5
9 fun addCondition (c : condition) (q : tag_query) : tag_query = 9 fun addCondition (c : condition) (q : tag_query) : tag_query =
10 case c.Mode of 10 case c.Mode of
11 Present => (SELECT I.Id AS Id 11 Present => (SELECT I.Id AS Id
12 FROM ({{q}}) AS I 12 FROM ({{q}}) AS I
13 JOIN tags ON tags.Id = I.Id AND tags.Tag = {[c.Tag]}) 13 JOIN tags ON tags.Id = I.Id AND tags.Tag = {[c.Tag]})
14 | Absent => q 14 | Absent => (SELECT I.Id AS Id
15 FROM ({{q}}) AS I
16 LEFT JOIN tags ON tags.Id = I.Id AND tags.Tag = {[c.Tag]}
17 WHERE tags.Tag IS NULL)
15 18
16 fun withConditions (cs : list condition) : tag_query = 19 fun withConditions (cs : list condition) : tag_query =
17 List.foldl addCondition (SELECT images.Id AS Id FROM images) cs 20 List.foldl addCondition (SELECT images.Id AS Id FROM images) cs
18 21
19 fun main (cs : list condition) : transaction page = 22 fun main (cs : list condition) : transaction page =