Skip to content

Commit

Permalink
$ne in prog
Browse files Browse the repository at this point in the history
  • Loading branch information
dwight committed Oct 10, 2008
1 parent 732e137 commit 6ff1bb8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions db/jsobj.cpp
Expand Up @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion db/jsobj.h
Expand Up @@ -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 {
Expand All @@ -512,7 +515,8 @@ class JSMatcher : boost::noncopyable {
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) {
Expand Down
5 changes: 5 additions & 0 deletions db/matcher.cpp
Expand Up @@ -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;
Expand All @@ -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...
Expand Down

0 comments on commit 6ff1bb8

Please sign in to comment.