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

Peter Brottveit Bock post at peterbb.net
Thu Nov 2 15:59:19 EDT 2017


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