Skip to content
This repository
Browse code

[fix] compiler, database, mongo: Fix preprocessing of querying of maps

  • Loading branch information...
commit 3b35aa8caf78a4b982d085cae04aecb0c759fc60 1 parent 25620b0
Quentin Bourgerie BourgerieQuentin authored

Showing 1 changed file with 16 additions and 1 deletion. Show diff stats Hide diff stats

  1. +16 1 opa/pass_MongoAccessGeneration.ml
17 opa/pass_MongoAccessGeneration.ml
@@ -481,7 +481,22 @@ module Generator = struct
481 481 | Some i -> annotmap, i
482 482 in let query = Some (
483 483 match setkind with
484   - | DbSchema.Map _ -> uniq, DbAst.QFlds [(["_id"], query)]
  484 + | DbSchema.Map _ ->
  485 + let rec insert_id query = match query with
  486 + | DbAst.QEq _
  487 + | DbAst.QGt _
  488 + | DbAst.QLt _
  489 + | DbAst.QGte _
  490 + | DbAst.QLte _
  491 + | DbAst.QNe _
  492 + | DbAst.QMod _
  493 + | DbAst.QIn _ -> DbAst.QFlds [(["_id"], query)]
  494 + | DbAst.QFlds flds -> DbAst.QFlds (List.map (fun (flds, q) -> ("_id"::flds, q)) flds)
  495 + | DbAst.QNot q -> DbAst.QNot (insert_id q)
  496 + | DbAst.QAnd (q1, q2) -> DbAst.QAnd (insert_id q1, insert_id q2)
  497 + | DbAst.QOr (q1, q2) -> DbAst.QOr (insert_id q1, insert_id q2)
  498 + in
  499 + uniq, insert_id query
485 500 | _ -> uniq, query
486 501 )
487 502 in

0 comments on commit 3b35aa8

Please sign in to comment.
Something went wrong with that request. Please try again.