Mercurial > urweb
changeset 2160:72fe1cc704c5
Tag NULLs with their types in SQL, to help the DBMS do type inference
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 04 Jul 2015 19:24:26 -0400 |
parents | 9029e0e2c67c |
children | af3f5b58aed2 |
files | src/monoize.sml |
diffstat | 1 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/monoize.sml Sat Jul 04 18:44:52 2015 -0400 +++ b/src/monoize.sml Sat Jul 04 19:24:26 2015 -0400 @@ -2214,6 +2214,19 @@ let val t = monoType env t val s = (L'.TFfi ("Basis", "string"), loc) + + fun toSqlType (t : L'.typ) = + case #1 t of + L'.TFfi ("Basis", "int") => Settings.Int + | L'.TFfi ("Basis", "float") => Settings.Float + | L'.TFfi ("Basis", "string") => Settings.String + | L'.TFfi ("Basis", "char") => Settings.Char + | L'.TFfi ("Basis", "bool") => Settings.Bool + | L'.TFfi ("Basis", "time") => Settings.Time + | L'.TFfi ("Basis", "blob") => Settings.Blob + | L'.TFfi ("Basis", "channel") => Settings.Channel + | L'.TFfi ("Basis", "client") => Settings.Client + | _ => raise Fail "Monoize/sql_option_prim: invalid SQL type" in ((L'.EAbs ("f", (L'.TFun (t, s), loc), @@ -2223,7 +2236,7 @@ s, (L'.ECase ((L'.ERel 0, loc), [((L'.PNone t, loc), - str "NULL"), + str (#p_cast (Settings.currentDbms ()) ("NULL", toSqlType t))), ((L'.PSome (t, (L'.PVar ("y", t), loc)), loc), (L'.EApp ((L'.ERel 2, loc), (L'.ERel 0, loc)), loc))], {disc = (L'.TOption t, loc),