diff options
-rw-r--r-- | db/jsobj.cpp | 4 | ||||
-rw-r--r-- | db/jsobj.h | 6 | ||||
-rw-r--r-- | db/matcher.cpp | 5 |
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 62b6403e025..14100030e98 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; @@ -221,6 +222,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... |