adam@6
|
1 fun sqexps [env] [fields] (fl : folder fields) (inj : $(map sql_injectable fields)) (r : $fields) =
|
adam@6
|
2 @map2 [sql_injectable] [id] [sql_exp env [] []]
|
adam@6
|
3 (fn [t] => @sql_inject)
|
adam@6
|
4 fl inj r
|
adam@6
|
5
|
adam@6
|
6 fun selector [tn :: Name] [fs] [ofs] [fs ~ ofs] (fl : folder fs) (m : $(map sql_injectable fs)) (r : $fs) =
|
adam@6
|
7 @foldR2 [sql_injectable] [id]
|
adam@6
|
8 [fn key => rest :: {Type} -> [rest ~ key] => sql_exp [tn = key ++ rest] [] [] bool]
|
adam@6
|
9 (fn [nm :: Name] [t :: Type] [key :: {Type}] [[nm] ~ key]
|
adam@6
|
10 (inj : sql_injectable t) (v : t)
|
adam@6
|
11 (exp : rest :: {Type} -> [rest ~ key] => sql_exp [tn = key ++ rest] [] [] bool)
|
adam@6
|
12 [rest :: {Type}] [rest ~ [nm = t] ++ key] =>
|
adam@6
|
13 (WHERE {{tn}}.{nm} = {@sql_inject inj v} AND {exp [[nm = t] ++ rest] !}))
|
adam@6
|
14 (fn [rest :: {Type}] [rest ~ []] => (WHERE TRUE))
|
adam@6
|
15 fl m r [_] !
|
adam@13
|
16
|
adam@13
|
17 fun joiner [tn1 :: Name] [tn2 :: Name] [fs] [ofs1] [ofs2] [[tn1] ~ [tn2]] [fs ~ ofs1] [fs ~ ofs2]
|
adam@13
|
18 (fl : folder fs) =
|
adam@13
|
19 @fold
|
adam@13
|
20 [fn key => rest1 :: {Type} -> rest2 :: {Type} -> [rest1 ~ key] => [rest2 ~ key] => sql_exp [tn1 = key ++ rest1, tn2 = key ++ rest2] [] [] bool]
|
adam@13
|
21 (fn [nm :: Name] [t :: Type] [key :: {Type}] [[nm] ~ key]
|
adam@13
|
22 (exp : rest1 :: {Type} -> rest2 :: {Type} -> [rest1 ~ key] => [rest2 ~ key]
|
adam@13
|
23 => sql_exp [tn1 = key ++ rest1, tn2 = key ++ rest2] [] [] bool)
|
adam@13
|
24 [rest1 :: {Type}] [rest2 :: {Type}] [rest1 ~ [nm = t] ++ key] [rest2 ~ [nm = t] ++ key] =>
|
adam@13
|
25 (WHERE {{tn1}}.{nm} = {{tn2}}.{nm} AND {exp [[nm = t] ++ rest1] [[nm = t] ++ rest2] ! !}))
|
adam@13
|
26 (fn [rest1 :: {Type}] [rest2 :: {Type}] [rest1 ~ []] [rest2 ~ []] => (WHERE TRUE))
|
adam@13
|
27 fl [_] [_] ! !
|