Permalink
Browse files

[fix] compiler, database, mongo: Handle special update case for some …

…update operations
  • Loading branch information...
1 parent b3abbf4 commit 25620b007b109cd79eb1855e4bc79a356dc2e96e @BourgerieQuentin BourgerieQuentin committed Apr 2, 2012
Showing with 11 additions and 4 deletions.
  1. +11 −4 opa/pass_MongoAccessGeneration.ml
@@ -361,10 +361,17 @@ module Generator = struct
let annotmap, uexpr =
if ty_is_sum gamma dataty then (
let annotmap, uexpr = update_to_expr ~set:false gamma annotmap u in
- let annotmap, _id =
- C.string annotmap (Format.sprintf "/%a" (Format.pp_list "/" Format.pp_print_string) strpath)
- in
- add_to_document gamma annotmap "_id" _id uexpr
+ match u with
+ | DbAst.UExpr _ ->
+ (* Special case for upsert without '$' modifier, needs
+ _id to the update query. *)
+ let _id =
+ (Format.sprintf "/%a"
+ (Format.pp_list "/" Format.pp_print_string) strpath)
+ in
+ let annotmap, _id = C.string annotmap _id in
+ add_to_document gamma annotmap "_id" _id uexpr
+ | _ -> annotmap, uexpr
) else (
let u =
if ty_is_const gamma dataty then DbAst.UFlds [["value"], u]

0 comments on commit 25620b0

Please sign in to comment.