Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[fix] stdlib: Added missing minkey and maxkey elements.

  • Loading branch information...
commit f13de226b565b78b3004b64ac26ca8e024a370eb 1 parent d442546
@nrs135 nrs135 authored
View
10 libbase/bson.ml
@@ -200,6 +200,12 @@ struct
let null b name =
estart b el_null name
+ let minkey b name =
+ estart b el_minkey name
+
+ let maxkey b name =
+ estart b el_maxkey name
+
let undefined b name =
estart b el_undefined name
@@ -549,7 +555,7 @@ struct
else
let ds =
match S.get i.ibuf i.pos with
- | c when c = el_undefined || c = el_null ->
+ | c when c = el_undefined || c = el_null || c = el_minkey || c = el_minkey ->
0
| c when c = el_bool ->
1
@@ -641,6 +647,8 @@ struct
| c when c = el_bindata -> Printf.printf "el_bindata"
| c when c = el_undefined -> Printf.printf "el_undefined"
| c when c = el_null -> Printf.printf "el_null"
+ | c when c = el_minkey -> Printf.printf "el_minkey"
+ | c when c = el_maxkey -> Printf.printf "el_maxkey"
| c when c = el_regex -> Printf.printf "el_regex: %s" (Iterator.regex i)
| c when c = el_code -> Printf.printf "el_code: %s" (Iterator.code i)
| c when c = el_codewscope ->
View
4 libbase/bson.mli
@@ -104,6 +104,8 @@ val el_oid : char
val el_bool : char
val el_date : char
val el_null : char
+val el_minkey : char
+val el_maxkey : char
val el_regex : char
val el_dbref : char
val el_code : char
@@ -147,6 +149,8 @@ module Append :
val double : buf -> S.t -> float -> unit
val bool : buf -> S.t -> bool -> unit
val null : buf -> S.t -> unit
+ val minkey : buf -> S.t -> unit
+ val maxkey : buf -> S.t -> unit
val undefined : buf -> S.t -> unit
val string_base : buf -> S.t -> S.t -> int -> char -> unit
val string : buf -> S.t -> S.t -> unit
View
8 opabsl/mlbsl/bslMongo.ml
@@ -99,6 +99,8 @@ let serialize bsons b =
| Some "Boolean" -> Bson.Append.bool b name (ServerLib.unwrap_bool value)
| Some "Date" ->Bson.Append.date b name (ServerLib.unwrap_int value)
| Some "Null" -> Bson.Append.null b name
+ | Some "Min" -> Bson.Append.minkey b name
+ | Some "Max" -> Bson.Append.maxkey b name
| Some "Regexp" ->
(match BslNativeLib.ocaml_tuple_2 value with
| (regexp, regexp_opts) ->
@@ -141,6 +143,8 @@ let field_bool = ServerLib.static_field_of_name "Boolean"
let field_string = ServerLib.static_field_of_name "String"
let field_document = ServerLib.static_field_of_name "Document"
let field_null = ServerLib.static_field_of_name "Null"
+let field_minkey = ServerLib.static_field_of_name "Min"
+let field_maxkey = ServerLib.static_field_of_name "Max"
let field_array = ServerLib.static_field_of_name "Array"
let field_binary = ServerLib.static_field_of_name "Binary"
let field_objectid = ServerLib.static_field_of_name "ObjectID"
@@ -166,6 +170,8 @@ let make_val fld n x =
make_element n (ServerLib.make_record (ServerLib.add_field ServerLib.empty_record_constructor fld x))
let make_null = make_val field_null
+let make_minkey = make_val field_minkey
+let make_maxkey = make_val field_maxkey
let make_int32 = make_val field_int32
let make_int64 = make_val field_int64
let make_double = make_val field_double
@@ -206,6 +212,8 @@ let deserialize s =
| c when c = Bson.el_oid -> let e = make_objectid (Bson.IteratorSS.key i) (Bson.IteratorSS.oid i) in auxn e i
| c when c = Bson.el_date -> let e = make_date (Bson.IteratorSS.key i) (Bson.IteratorSS.date i) in auxn e i
| c when c = Bson.el_null -> let e = make_null (Bson.IteratorSS.key i) ServerLib.void in auxn e i
+ | c when c = Bson.el_minkey -> let e = make_minkey (Bson.IteratorSS.key i) ServerLib.void in auxn e i
+ | c when c = Bson.el_maxkey -> let e = make_maxkey (Bson.IteratorSS.key i) ServerLib.void in auxn e i
| c when c = Bson.el_regex ->
let e = make_regexp (Bson.IteratorSS.key i) (Bson.IteratorSS.regex i) (Bson.IteratorSS.regex_opts i) in auxn e i
| c when c = Bson.el_code -> let e = make_code (Bson.IteratorSS.key i) (Bson.IteratorSS.code i) in auxn e i
View
2  stdlib/apis/mongo/MongoDb.opa
@@ -726,6 +726,8 @@ SU : SU = {{
| {Int32=_} -> ({su_either},T.tint)
| {Timestamp=_} -> ({su_either},T.ttimestamp)
| {Int64=_} -> ({su_either},T.tint)
+ | {Min=_} -> ({su_select},T.tvoid)
+ | {Max=_} -> ({su_select},T.tvoid)
@private sutymrg((sut,ty), (asut,aty)) = (merge(sut,asut),T.tmrgrecs(ty,aty))
View
12 stdlib/apis/mongo/mongo.opa
@@ -86,7 +86,7 @@ type Bson.value =
/ { ObjectID: string }
/ { Boolean: bool }
/ { Date: Date.date }
- / { Null: void } // TODO: ditch the void
+ / { Null }
/ { Regexp: (string, string) }
/ { Code: string }
/ { Symbol: string }
@@ -94,6 +94,8 @@ type Bson.value =
/ { Int32: int }
/ { Timestamp: (int, int) }
/ { Int64: int }
+ / { Min }
+ / { Max }
@opacapi
type Bson.element = { name:string; value:Bson.value }
@@ -173,6 +175,8 @@ Bson = {{
tInt32 = 0x10
tTimestamp = 0x11
tInt64 = 0x12
+ tMin = 0xff
+ tMax = 0x7f
/** Convenience function, dump string as hex and ascii */
dump = (%% BslMongo.Bson.dump %%: int, string -> string)
@@ -207,6 +211,8 @@ Bson = {{
| {Int32=_} -> tInt32
| {Timestamp=_} -> tTimestamp
| {Int64=_} -> tInt64
+ | {Min=_} -> tMin
+ | {Max=_} -> tMax
/**
* Return the key of an element.
@@ -344,6 +350,8 @@ Bson = {{
| {Int32=v} -> "Int32 {v}"
| {Timestamp=(t,i)} -> "Timestamp \{ \"t\" : {t}, \"i\" : {i}"
| {Int64=v} -> "Int64 {v}"
+ | {Min=_} -> "Min"
+ | {Max=_} -> "Max"
string_of_element(element:Bson.element): string = "\"{element.name}\" : {string_of_value(element.value)}"
@@ -374,6 +382,8 @@ Bson = {{
| {Int32=v} -> "{v}"
| {Timestamp=(t,i)} -> "\{ \"t\" : {t}, \"i\" : {i} \}"
| {Int64=v} -> "{v}L"
+ | {Min=_} -> "min"
+ | {Max=_} -> "max"
pretty_of_element(element:Bson.element): string =
"\"{element.name}\" : {pretty_of_value(element.value)}"
Please sign in to comment.
Something went wrong with that request. Please try again.