comparison sql.urs @ 15:6ebc2ca594b7

Sql.insertIfMissing and deleteByKey (partly from Ron de Bruijn)
author Adam Chlipala <adam@chlipala.net>
date Sun, 11 Dec 2011 14:04:34 -0500
parents d05943db55e8
children 959583692166
comparison
equal deleted inserted replaced
14:744bf911dcc6 15:6ebc2ca594b7
13 val joiner : tn1 :: Name -> tn2 :: Name -> fs ::: {Type} -> ofs1 ::: {Type} -> ofs2 ::: {Type} 13 val joiner : tn1 :: Name -> tn2 :: Name -> fs ::: {Type} -> ofs1 ::: {Type} -> ofs2 ::: {Type}
14 -> [[tn1] ~ [tn2]] => [fs ~ ofs1] => [fs ~ ofs2] 14 -> [[tn1] ~ [tn2]] => [fs ~ ofs1] => [fs ~ ofs2]
15 => folder fs 15 => folder fs
16 -> sql_exp [tn1 = ofs1 ++ fs, tn2 = ofs2 ++ fs] [] [] bool 16 -> sql_exp [tn1 = ofs1 ++ fs, tn2 = ofs2 ++ fs] [] [] bool
17 (* Declare equality of same-named columns from two tables. *) 17 (* Declare equality of same-named columns from two tables. *)
18
19 val insertIfMissing : keyCols ::: {Type} -> otherCols ::: {Type} -> otherKeys ::: {{Unit}}
20 -> [keyCols ~ otherCols] => [[Pkey] ~ otherKeys]
21 => sql_table (keyCols ++ otherCols) ([Pkey = map (fn _ => ()) keyCols] ++ otherKeys)
22 -> $(keyCols ++ otherCols)
23 -> folder keyCols -> $(map sql_injectable keyCols)
24 -> folder otherCols -> $(map sql_injectable otherCols)
25 -> transaction bool
26 (* Insert a row into an SQL table if its key isn't already present, returning [False] iff the key was already present *)
27
28 val deleteByKey : keyCols ::: {Type} -> otherCols ::: {Type} -> otherKeys ::: {{Unit}}
29 -> [keyCols ~ otherCols] => [[Pkey] ~ otherKeys]
30 => sql_table (keyCols ++ otherCols) ([Pkey = map (fn _ => ()) keyCols] ++ otherKeys)
31 -> $keyCols -> folder keyCols -> $(map sql_injectable keyCols)
32 -> transaction {}
33 (* Delete a row from a table by matching its primary key against a given record. *)