summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/jsobj.cpp22
-rw-r--r--db/testdb.js15
-rw-r--r--grid/message.cpp4
3 files changed, 30 insertions, 11 deletions
diff --git a/db/jsobj.cpp b/db/jsobj.cpp
index 551d020a610..2307f56cd44 100644
--- a/db/jsobj.cpp
+++ b/db/jsobj.cpp
@@ -3,6 +3,7 @@
#include "stdafx.h"
#include "jsobj.h"
#include "../util/goodies.h"
+#include <ctime>
Element nullElement;
@@ -201,9 +202,26 @@ bool JSMatcher::matches(JSObj& jsobj, bool *deep) {
return false;
Element e = k.next();
if( strcmp(e.fieldName(), rm.fieldName) == 0 ) {
- if( e.type() != String )
+ char buf[64];
+ const char *p = buf;
+ if( e.type() == String )
+ p = e.valuestr();
+ else if( e.type() == Number ) {
+ sprintf(buf, "%Lf", e.number());
+ }
+ else if( e.type() == Date ) {
+ unsigned long long d = e.date();
+ time_t t = (d/1000);
+#if defined(_WIN32)
+ ctime_s(buf, 64, &t);
+#else
+ ctime_r(&t, buf);
+ cout << "CTIME:" << buf << endl;
+#endif
+ }
+ else
return false;
- if( !rm.re->PartialMatch(e.valuestr()) )
+ if( !rm.re->PartialMatch(p) )
return false;
break;
}
diff --git a/db/testdb.js b/db/testdb.js
index c0036e9d067..9acbec1a7ca 100644
--- a/db/testdb.js
+++ b/db/testdb.js
@@ -2,16 +2,14 @@
var fail = 0;
-var t = connect("test", "192.168.79.1");
+var t = connect("test");
var z = 0;
function progress() {}// print(++z); }
function failure(f, args) {
- print("FAIL: " + f);
- fail++;
- if( args.length >= 2 )
- print(args[1]);
+ print("FAIL: " + f + ' ' + (args.length<2?"":args[1]));
+ fail++;
}
function assert(x) {
@@ -113,15 +111,16 @@ function runquick() {
assert( t.nullcheck.find({a:3})[0].a == 3, "a3" );
oneresult( t.nullcheck.find( { b: null } ) ); progress();
noresult( t.nullcheck.find( { b: 1 } ) ); progress();
- print("this one doesn't work yet todo:");
- oneresult( t.nullcheck.find( { a : "3" } ) ); progress();
+ oneresult( t.nullcheck.find( { a : "3" } ), "todo num to str match" ); progress();
// regex
print("regex");
t.reg.remove({});
- t.reg.save( { name: "Dwight" } );
+ t.reg.save( { name: "Dwight", a : 345, dt: Date() } );
for( i = 0; i < 2; i++ ) {
oneresult( t.reg.find( { name: /Dwi./ } ), "re1" );
+ oneresult( t.reg.find( { dt: /20/ } ), "date regexp match" );
+ oneresult( t.reg.find( { a: /34/ } ), "regexp match number" );
noresult( t.reg.find( { name: /dwi./ } ), "re2" );
oneresult( t.reg.find( { name: /dwi/i } ), "re3" );
t.reg.ensureIndex( { name: true } );
diff --git a/grid/message.cpp b/grid/message.cpp
index d39b145260e..8831a9c6246 100644
--- a/grid/message.cpp
+++ b/grid/message.cpp
@@ -18,7 +18,9 @@ void Listener::listen() {
return;
}
if( bind(sock, (sockaddr *) &me.sa, me.addressSize) != 0 ) {
- cout << "listen(): bind() failed" << errno << endl;
+ cout << "listen(): bind() failed errno:" << errno << endl;
+ if( errno == 98 )
+ cout << "98 == addr already in use" << endl;
closesocket(sock);
return;
}