Skip to content

Commit

Permalink
Support "continue_on_error" argument to insert_batch method.
Browse files Browse the repository at this point in the history
  • Loading branch information
lehenbauer committed Feb 12, 2014
1 parent e2aaed8 commit ec8f948
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions generic/mongotcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,12 +807,21 @@ mongotcl_mongoObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_O
int listObjc;
int i;
Tcl_Obj **listObjv;
int flags = 0;

if (objc != 4) {
Tcl_WrongNumArgs (interp, 2, objv, "namespace bsonList");
if (objc < 4 || objc > 5) {
Tcl_WrongNumArgs (interp, 2, objv, "namespace bsonList ?continue_on_error?");
return TCL_ERROR;
}

if (objc == 5) {
if (strcmp (Tcl_GetString (objv[4]), "continue_on_error") != 0) {
Tcl_SetObjResult (interp, Tcl_NewStringObj ("fifth argument is not 'continue_on_error'", -1));
return TCL_ERROR;
}
flags = MONGO_CONTINUE_ON_ERROR;
}

/* retrieve the list of bson objects */
if (Tcl_ListObjGetElements (interp, objv[3], &listObjc, &listObjv) == TCL_ERROR) {
Tcl_AddErrorInfo (interp, "while getting bson objects from list");
Expand All @@ -827,7 +836,7 @@ mongotcl_mongoObjectObjCmd(ClientData cData, Tcl_Interp *interp, int objc, Tcl_O
}
}

if (mongo_insert_batch (md->conn, Tcl_GetString(objv[2]), bsonList, listObjc, md->write_concern, 0) != MONGO_OK) {
if (mongo_insert_batch (md->conn, Tcl_GetString(objv[2]), bsonList, listObjc, md->write_concern, flags) != MONGO_OK) {
return mongotcl_setMongoError (interp, md->conn);
}

Expand Down

0 comments on commit ec8f948

Please sign in to comment.