[Ur] No sql_injectable(_prim) xbody (or xml in general).

Adam Chlipala adamc at csail.mit.edu
Thu Nov 2 16:08:24 EDT 2017


You're right that there are currently no type-class instances for 
storing XML in the SQL database.  At the moment, I can't remember any 
good reasons for not adding an instance for all [xml] types. I'll plan 
to do it, if no one adds a counterargument here in the next few days!

On 11/02/2017 03:59 PM, Peter Brottveit Bock wrote:
> Hi,
>
> It seems to me that it's not possible to store xml in a database. Is there any reason for this?
>
> My understanding of ur/web is that the xml data type is—under the hood—simply a string. I therefore would have thought it would be trivial to store it in a database.
>
> As a minimal example:
>
> ------------------
> table db : { Elem : xbody }
>
> fun display_db () =
>      queryX (SELECT * FROM db)
>             (fn row => row.Db.Elem)
>
> fun add_to_db (x : xbody) : transaction unit =
>      dml (INSERT INTO db(Elem) VALUES ({[x]}))
>
> fun main () =
>      add_to_db <xml> Hello </xml>;
>      display_db ()
> ------------------
>
> fails with
> ------------------
> example.ur:5:38: (to 5:43) Can't resolve type class instance
>         Class constraint:
> sql_injectable (xml ([Dyn = (), MakeForm = (), Body = ()]) ([]) ([]))
> Reduced to unresolvable:
> sql_injectable_prim
>   (xml ([Dyn = (), MakeForm = (), Body = ()]) ([]) ([]))
> ------------------
>
> — Peter



More information about the Ur mailing list