summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-10-10 11:10:21 -0400
committerDwight <dmerriman@gmail.com>2008-10-10 11:10:21 -0400
commit6ff1bb8bf193aa973781b205af1d73cc60782e90 (patch)
tree5d44b41b8603a3c4bc1c911c56c23a75d9c4fa3b
parent732e1371190186799ace0d01cd3bf5930c401995 (diff)
downloadmongo-6ff1bb8bf193aa973781b205af1d73cc60782e90.tar.gz
$ne in prog
-rw-r--r--db/jsobj.cpp4
-rw-r--r--db/jsobj.h6
-rw-r--r--db/matcher.cpp5
3 files changed, 14 insertions, 1 deletions
diff --git a/db/jsobj.cpp b/db/jsobj.cpp
index d830c8ca8c7..51ec0b96ccd 100644
--- a/db/jsobj.cpp
+++ b/db/jsobj.cpp
@@ -239,6 +239,10 @@ int getGtLtOp(Element& e) {
else if( fn[3] == 'e' && fn[4] == 0 ) op = JSMatcher::LTE;
}
}
+ else if( fn[2] == 'e' ) {
+ if( fn[1] == 'n' && fn[3] == 0 )
+ op = JSMatcher::NE;
+ }
else if( fn[1] == 'i' && fn[2] == 'n' && fn[3] == 0 )
op = JSMatcher::opIN;
}
diff --git a/db/jsobj.h b/db/jsobj.h
index 7aa1c5113bb..7a79906d815 100644
--- a/db/jsobj.h
+++ b/db/jsobj.h
@@ -487,6 +487,9 @@ class Where;
GT/LT:
{ a : { $gt : 3 } }
+ Not equal:
+ { a : { $ne : 3 } }
+
TODO: we should rewrite the matcher to be more an AST style.
*/
class JSMatcher : boost::noncopyable {
@@ -512,7 +515,8 @@ public:
LTE = 0x3,
GTE = 0x6,
GT = 0x4,
- opIN = 0x8 // { x : { $in : [1,2,3] } }
+ opIN = 0x8, // { x : { $in : [1,2,3] } }
+ NE = 0x9
};
static int opDirection(int op) {
diff --git a/db/matcher.cpp b/db/matcher.cpp
index 286e011049a..8a4c74a333b 100644
--- a/db/matcher.cpp
+++ b/db/matcher.cpp
@@ -193,6 +193,7 @@ JSMatcher::JSMatcher(JSObj &_jsobj) :
break;
// Element fe = e.embeddedObject().firstElement();
const char *fn = fe.fieldName();
+ /* TODO: use getGtLtOp() here. this code repeats ourself */
if( fn[0] == '$' && fn[1] ) {
if( fn[2] == 't' ) {
int op = Equality;
@@ -214,6 +215,10 @@ JSMatcher::JSMatcher(JSObj &_jsobj) :
ok = true;
}
}
+ else if( fn[2] == 'e' ) {
+ if( fn[1] == 'n' && fn[3] == 0 ) {
+ }
+ }
else if( fn[1] == 'i' && fn[2] == 'n' && fn[3] == 0 && fe.type() == Array ) {
// $in
assert( in == 0 ); // only one per query supported so far. finish...