summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-05-28 10:54:48 -0400
committerEliot Horowitz <eliot@10gen.com>2009-05-28 10:54:48 -0400
commit31c52cba69d122146c00d47a72a361d39412d775 (patch)
tree8a3dca9d602a55dd9d98f827beb44c469c9c25ee /scripting
parente8a92a31f47eed060d2e056a54b334a4e7423aa9 (diff)
downloadmongo-31c52cba69d122146c00d47a72a361d39412d775.tar.gz
make "new ObjectId()" and "ObjectId()" both work for backwards compatability
Diffstat (limited to 'scripting')
-rw-r--r--scripting/sm_db.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/scripting/sm_db.cpp b/scripting/sm_db.cpp
index edf7b245f74..a27d7438b1e 100644
--- a/scripting/sm_db.cpp
+++ b/scripting/sm_db.cpp
@@ -390,7 +390,6 @@ namespace mongo {
// -------------- object id -------------
JSBool object_id_constructor( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval ){
-
Convertor c( cx );
OID oid;
@@ -401,7 +400,13 @@ namespace mongo {
uassert( "object_id_constructor can't take more than 1 param" , argc == 1 );
oid.init( c.toString( argv[0] ) );
}
-
+
+ if ( ! JS_InstanceOf( cx , obj , &object_id_class , 0 ) ){
+ obj = JS_NewObject( cx , &object_id_class , 0 , 0 );
+ assert( obj );
+ *rval = OBJECT_TO_JSVAL( obj );
+ }
+
jsval v = c.toval( oid.str().c_str() );
assert( JS_SetProperty( cx , obj , "str" , &v ) );