Skip to content

Commit

Permalink
[fix] compiler, database, mongo: Take care of field encoding/decoding…
Browse files Browse the repository at this point in the history
… for maps
  • Loading branch information
BourgerieQuentin committed Apr 17, 2012
1 parent 764d33d commit 4a8c34e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions opa/pass_MongoAccessGeneration.ml
Expand Up @@ -91,14 +91,14 @@ module Generator = struct
in
C.apply gamma annotmap opa2doc [expr]

let magicToString gamma annotmap expr
let expr_to_field gamma annotmap expr
?(ty=QmlAnnotMap.find_ty (Annot.annot (QmlAst.Label.expr expr)) annotmap)
()
=
let (annotmap, magicToString) =
OpaMapToIdent.typed_val ~label ~ty:[ty] Opacapi.magicToString annotmap gamma
let annotmap, expr_to_field =
OpaMapToIdent.typed_val ~label ~ty:[ty] Opacapi.DbMongo.expr_to_field annotmap gamma
in
C.apply gamma annotmap magicToString [expr]
C.apply gamma annotmap expr_to_field [expr]

let add_to_document0 gamma annotmap name expr
?(ty=QmlAnnotMap.find_ty (Annot.annot (QmlAst.Label.expr expr)) annotmap)
Expand Down Expand Up @@ -141,7 +141,7 @@ module Generator = struct
let annotmap, d = C.string annotmap "." in
annotmap, d::e::prev_expr
in
let annotmap, e1 = magicToString gamma annotmap e1 () in
let annotmap, e1 = expr_to_field gamma annotmap e1 () in
let annotmap, d1 = C.string annotmap "." in
if q = [] then
let annotmap, value = C.string annotmap "value" in
Expand Down Expand Up @@ -740,7 +740,7 @@ module Generator = struct
| DbAst.Query (DbAst.QEq uexpr , _)->
DbAst.SId (uexpr, select),
(fun ((annotmap, expr), dty) ->

post ((annotmap, expr), dty)

)
Expand Down
1 change: 1 addition & 0 deletions opacapi/opacapi.ml
Expand Up @@ -163,6 +163,7 @@ struct
let option = !! "option"
let read = !! "read"
let write = !! "write"
let expr_to_field = !! "expr_to_field"
end

module DbSet =
Expand Down
2 changes: 1 addition & 1 deletion stdlib/database/mongo/db.opa
Expand Up @@ -911,4 +911,4 @@ DbSet = {{
@opacapi DbSet_build_rpath_collection = DbSet.build_rpath_collection
@opacapi DbSet_default = Option.default
@opacapi DbSet_empty = {empty}
@opacapi DbMongo_expr_to_field(x) = %%BslMongo.Mongo.encode_field%%(OpaSerialize.serialize(x))

0 comments on commit 4a8c34e

Please sign in to comment.