# HG changeset patch # User Adam Chlipala # Date 1226004733 18000 # Node ID 4efab85405beacb04b993e37aadf8140d7e677f3 # Parent 3f1b9231a37b698b411be61971e17fe1f17ca8dd Ensql'ing nullables diff -r 3f1b9231a37b -r 4efab85405be src/cjr_print.sml --- a/src/cjr_print.sml Thu Nov 06 15:37:38 2008 -0500 +++ b/src/cjr_print.sml Thu Nov 06 15:52:13 2008 -0500 @@ -474,6 +474,13 @@ | EFfiApp ("Basis", "sqlifyString", [e]) => [(e, String)] | EFfiApp ("Basis", "sqlifyBool", [e]) => [(e, Bool)] | EFfiApp ("Basis", "sqlifyTime", [e]) => [(e, Time)] + + | EFfiApp ("Basis", "sqlifyIntN", [e]) => [(e, Nullable Int)] + | EFfiApp ("Basis", "sqlifyFloatN", [e]) => [(e, Nullable Float)] + | EFfiApp ("Basis", "sqlifyStringN", [e]) => [(e, Nullable String)] + | EFfiApp ("Basis", "sqlifyBoolN", [e]) => [(e, Nullable Bool)] + | EFfiApp ("Basis", "sqlifyTimeN", [e]) => [(e, Nullable Time)] + | ECase (e, _, _) => [(e, Bool)] | _ => raise Fail "CjrPrint: getPargs" diff -r 3f1b9231a37b -r 4efab85405be src/monoize.sml --- a/src/monoize.sml Thu Nov 06 15:37:38 2008 -0500 +++ b/src/monoize.sml Thu Nov 06 15:52:13 2008 -0500 @@ -983,7 +983,7 @@ let val (e, fm) = monoExp (env, st, fm) e in - ((L'.EDml (liftExpInExp 0 e), loc), + ((L'.EDml e, loc), fm) end diff -r 3f1b9231a37b -r 4efab85405be src/prepare.sml --- a/src/prepare.sml Thu Nov 06 15:37:38 2008 -0500 +++ b/src/prepare.sml Thu Nov 06 15:52:13 2008 -0500 @@ -47,6 +47,18 @@ SOME ("$" ^ Int.toString (n + 1) ^ "::bool" :: ss, n + 1) | EFfiApp ("Basis", "sqlifyTime", [e]) => SOME ("$" ^ Int.toString (n + 1) ^ "::timestamp" :: ss, n + 1) + + | EFfiApp ("Basis", "sqlifyIntN", [e]) => + SOME ("$" ^ Int.toString (n + 1) ^ "::int8" :: ss, n + 1) + | EFfiApp ("Basis", "sqlifyFloatN", [e]) => + SOME ("$" ^ Int.toString (n + 1) ^ "::float8" :: ss, n + 1) + | EFfiApp ("Basis", "sqlifyStringN", [e]) => + SOME ("$" ^ Int.toString (n + 1) ^ "::text" :: ss, n + 1) + | EFfiApp ("Basis", "sqlifyBoolN", [e]) => + SOME ("$" ^ Int.toString (n + 1) ^ "::bool" :: ss, n + 1) + | EFfiApp ("Basis", "sqlifyTimeN", [e]) => + SOME ("$" ^ Int.toString (n + 1) ^ "::timestamp" :: ss, n + 1) + | ECase (e, [((PCon (_, PConFfi {mod = "Basis", con = "True", ...}, _), _), (EPrim (Prim.String "TRUE"), _)), diff -r 3f1b9231a37b -r 4efab85405be tests/sql_option.ur --- a/tests/sql_option.ur Thu Nov 06 15:37:38 2008 -0500 +++ b/tests/sql_option.ur Thu Nov 06 15:52:13 2008 -0500 @@ -4,9 +4,13 @@ dml (INSERT INTO t (O) VALUES (NULL)); return Done -(*fun add42 () = - dml (INSERT INTO t (O) VALUES (42)); - return Done*) +fun add3 () = + dml (INSERT INTO t (O) VALUES ({Some 3})); + return Done + +fun addN r = + dml (INSERT INTO t (O) VALUES ({Some (readError r.N)})); + return Done fun main () : transaction page = xml <- queryX (SELECT * FROM t) @@ -17,6 +21,8 @@ {xml} Add a null
+ Add a 3
+
+ Add + - -(* Add a 42
*) diff -r 3f1b9231a37b -r 4efab85405be tests/sql_option.urs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/sql_option.urs Thu Nov 06 15:52:13 2008 -0500 @@ -0,0 +1,1 @@ +val main : unit -> transaction page