comparison sql.ur @ 26:c1da0e3749b3

Sql.listify
author Adam Chlipala <adam@chlipala.net>
date Sun, 13 May 2012 14:13:18 -0400
parents 875221eee987
children
comparison
equal deleted inserted replaced
25:9f56676e7c4e 26:c1da0e3749b3
58 (vs : $keyCols) 58 (vs : $keyCols)
59 : transaction (option $otherCols) = 59 : transaction (option $otherCols) =
60 oneOrNoRows1 (SELECT t.{{otherCols}} 60 oneOrNoRows1 (SELECT t.{{otherCols}}
61 FROM t 61 FROM t
62 WHERE {@selector [#T] ! kfl kinj (vs --- _)}) 62 WHERE {@selector [#T] ! kfl kinj (vs --- _)})
63
64 fun listify [lead :: Name] [cols ::: {Type}] [rest ::: {{Type}}] [[lead] ~ rest]
65 (fl : folder cols) (eqs : $(map eq cols)) (q : sql_query [] [] ([lead = cols] ++ rest) []) =
66 query q
67 (fn r acc =>
68 return (case acc of
69 [] => (r.lead, (r -- lead) :: []) :: []
70 | (key, ls) :: acc' =>
71 if @Record.equal eqs fl r.lead key then
72 (key, (r -- lead) :: ls) :: acc'
73 else
74 (r.lead, (r -- lead) :: []) :: acc))
75 []