Permalink
Browse files

Implement the blob type for the sqlite backend. Afraid of the mysql b…

…ackend.
  • Loading branch information...
msullivan committed Feb 6, 2014
1 parent 80558ef commit ba45555493d056f04a6b23dfefa85cfd648b37e5
Showing with 5 additions and 1 deletion.
  1. +1 −0 db/squall/input.grm
  2. +1 −1 db/squall/input.sml
  3. +3 −0 db/squall/squall-sqlite.sml
View
@@ -4,6 +4,7 @@ exception ParseError of string
fun type_lookup "string" = String
| type_lookup "int" = Int
+ | type_lookup "blob" = Blob
| type_lookup t = raise ParseError ("Unknown type: \"" ^ t ^ "\"")
fun engine_lookup s =
View
@@ -2,7 +2,7 @@ structure SquallInput = struct
datatype engine = SQLite | MySQL
- datatype vartype = String | Int
+ datatype vartype = String | Int | Blob
datatype varspec = Vrequired of vartype | Voption of vartype | Vlist of vartype
@@ -14,6 +14,8 @@ end = struct
"SQLite.bind_int (s, " ^ Int.toString (pos + 1) ^ ", " ^ ivar ^ ")"
| generateBindFunc (ivar, pos, SI.String) =
"SQLite.bind_text (s, " ^ Int.toString (pos + 1) ^ ", " ^ ivar ^ ")"
+ | generateBindFunc (ivar, pos, SI.Blob) =
+ "SQLite.bind_blob (s, " ^ Int.toString (pos + 1) ^ ", " ^ ivar ^ ")"
(* val generateBind: string * int * varspec -> string
@@ -39,6 +41,7 @@ end = struct
*)
fun generateReader (idx, SI.Int) = "SQLite.column_int (s, " ^ Int.toString idx ^ ")"
| generateReader (idx, SI.String) = "(case SQLite.column_text (s, " ^ Int.toString idx ^ ")of SOME s=>s|_=>raise(DataFormatError\""^Int.toString idx ^ "\"))"
+ | generateReader (idx, SI.Blob) = "(case SQLite.column_blob (s, " ^ Int.toString idx ^ ")of SOME s=>s|_=>raise(DataFormatError\""^Int.toString idx ^ "\"))"
(* fun generateConv: int * varspec -> string
*

0 comments on commit ba45555

Please sign in to comment.