summaryrefslogtreecommitdiff
path: root/db/jsobj.h
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-08-25 10:52:17 -0400
committerEliot Horowitz <eliot@10gen.com>2009-08-25 10:52:17 -0400
commitf5d28ebb1b66560ced65c4a924201c06cd0e7199 (patch)
treedde9145bd65a356014e3f694b37af6e209e7c5b1 /db/jsobj.h
parent0a95fb0e7f67079039c9047f6df8f9d74bf71ff3 (diff)
downloadmongo-f5d28ebb1b66560ced65c4a924201c06cd0e7199.tar.gz
fix numeric sort order when comparing non numeric types
Diffstat (limited to 'db/jsobj.h')
-rw-r--r--db/jsobj.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/db/jsobj.h b/db/jsobj.h
index 711c539a2a7..9e19af7483d 100644
--- a/db/jsobj.h
+++ b/db/jsobj.h
@@ -205,6 +205,20 @@ namespace mongo {
BSONType type() const {
return (BSONType) *data;
}
+
+ /** returns the tyoe of the element fixed for the main type
+ the main purpose is numbers. any numeric type will return NumberDouble
+ */
+ BSONType canonicalType() const {
+ BSONType t = type();
+ switch ( t ){
+ case NumberInt:
+ case NumberLong:
+ return NumberDouble;
+ default:
+ return t;
+ }
+ }
/** Indicates if it is the end-of-object element, which is present at the end of
every BSON object.