comparison src/monoize.sml @ 2191:849404a3af27

Change behavior of SQL equality to do the intuitive thing for nullable types
author Adam Chlipala <adam@chlipala.net>
date Sun, 01 Nov 2015 17:02:16 -0500
parents 72fe1cc704c5
children 985c8016b592
comparison
equal deleted inserted replaced
2190:22117edf8fd3 2191:849404a3af27
2590 (L.ECApp ( 2590 (L.ECApp (
2591 (L.EFfi ("Basis", "sql_binary"), _), 2591 (L.EFfi ("Basis", "sql_binary"), _),
2592 _), _), 2592 _), _),
2593 _), _), 2593 _), _),
2594 _), _), 2594 _), _),
2595 _), _), 2595 arg1), _),
2596 _), _), 2596 _), _),
2597 _) => 2597 _) =>
2598 let 2598 let
2599 val s = (L'.TFfi ("Basis", "string"), loc) 2599 val s = (L'.TFfi ("Basis", "string"), loc)
2600
2601 val default = strcat [str "(",
2602 (L'.ERel 1, loc),
2603 str " ",
2604 (L'.ERel 2, loc),
2605 str " ",
2606 (L'.ERel 0, loc),
2607 str ")"]
2608
2609 val body = case #1 arg1 of
2610 L.CApp ((L.CFfi ("Basis", "option"), _), _) =>
2611 (L'.ECase ((L'.ERel 2, loc),
2612 [((L'.PPrim (Prim.String (Prim.Normal, "=")), loc),
2613 strcat [str "((",
2614 (L'.ERel 1, loc),
2615 str " ",
2616 (L'.ERel 2, loc),
2617 str " ",
2618 (L'.ERel 0, loc),
2619 str ") OR ((",
2620 (L'.ERel 1, loc),
2621 str ") IS NULL AND (",
2622 (L'.ERel 0, loc),
2623 str ") IS NULL))"]),
2624 ((L'.PWild, loc),
2625 default)],
2626 {disc = s,
2627 result = s}), loc)
2628 | _ => default
2600 in 2629 in
2601 ((L'.EAbs ("c", s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc), 2630 ((L'.EAbs ("c", s, (L'.TFun (s, (L'.TFun (s, s), loc)), loc),
2602 (L'.EAbs ("e1", s, (L'.TFun (s, s), loc), 2631 (L'.EAbs ("e1", s, (L'.TFun (s, s), loc),
2603 (L'.EAbs ("e2", s, s, 2632 (L'.EAbs ("e2", s, s,
2604 strcat [str "(", 2633 body), loc)), loc)), loc),
2605 (L'.ERel 1, loc),
2606 str " ",
2607 (L'.ERel 2, loc),
2608 str " ",
2609 (L'.ERel 0, loc),
2610 str ")"]), loc)), loc)), loc),
2611 fm) 2634 fm)
2612 end 2635 end
2613 | L.EFfi ("Basis", "sql_and") => (str "AND", fm) 2636 | L.EFfi ("Basis", "sql_and") => (str "AND", fm)
2614 | L.EFfi ("Basis", "sql_or") => (str "OR", fm) 2637 | L.EFfi ("Basis", "sql_or") => (str "OR", fm)
2615 2638