summaryrefslogtreecommitdiff
path: root/lib/top.ur
diff options
context:
space:
mode:
Diffstat (limited to 'lib/top.ur')
-rw-r--r--lib/top.ur13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/top.ur b/lib/top.ur
index abc70e53..5d00282c 100644
--- a/lib/top.ur
+++ b/lib/top.ur
@@ -226,3 +226,16 @@ fun oneRow (tables ::: {{Type}}) (exps ::: {Type})
None => error <xml>Query returned no rows</xml>
| Some r => r)
+fun eqNullable (tables ::: {{Type}}) (agg ::: {{Type}}) (exps ::: {Type})
+ (t ::: Type) (_ : sql_injectable (option t))
+ (e1 : sql_exp tables agg exps (option t))
+ (e2 : sql_exp tables agg exps (option t)) =
+ (SQL ({[e1]} IS NULL AND {[e2]} IS NULL) OR {[e1]} = {[e2]})
+
+fun eqNullable' (tables ::: {{Type}}) (agg ::: {{Type}}) (exps ::: {Type})
+ (t ::: Type) (inj : sql_injectable (option t))
+ (e1 : sql_exp tables agg exps (option t))
+ (e2 : option t) =
+ case e2 of
+ None => (SQL {[e1]} IS NULL)
+ | Some _ => sql_comparison sql_eq e1 (@sql_inject inj e2)