Permalink
Browse files

[fix] compiler, database, mongo: In sum case we won't add '' fields (…

…added on non UExpr branch)
  • Loading branch information...
1 parent bdc3853 commit 6ccb5cbd2d2b3b1603add842ed0fad59b78714a8 @BourgerieQuentin BourgerieQuentin committed Mar 9, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 opa/pass_MongoAccessGeneration.ml
@@ -214,6 +214,7 @@ module Generator = struct
add_to_document gamma annotmap "$set" uexpr empty
else annotmap, uexpr
| update ->
+ let addset = set in
let rec collect fld (inc, set, other, annotmap) update =
let rfld = if fld = "" then "value" else fld in
match update with
@@ -265,8 +266,12 @@ module Generator = struct
| (field, value)::q ->
aux (add_to_document gamma annotmap field value doc) q
in
- let annotmap, sexpr = aux (C.list (annotmap, gamma) []) set in
- add_to_document gamma annotmap "$set" sexpr uexpr
+ if addset then (
+ let annotmap, sexpr = aux (C.list (annotmap, gamma) []) set in
+ add_to_document gamma annotmap "$set" sexpr uexpr
+ ) else (
+ aux (C.list (annotmap, gamma) []) set
+ )
in
let annotmap, uexpr =
List.fold_left

0 comments on commit 6ccb5cb

Please sign in to comment.