Skip to content

Commit

Permalink
$cursor set_fields "field1 0 field2 1..." now works.
Browse files Browse the repository at this point in the history
BUGZID:
  • Loading branch information
lehenbauer committed Feb 15, 2014
1 parent c1900d0 commit 61455a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 9 additions & 5 deletions generic/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,21 @@ mongotcl_tcllist_to_cursor_fields (Tcl_Interp *interp, Tcl_Obj *fieldList, mongo
char *key = Tcl_GetString (listObjv[i]);

if (Tcl_GetIntFromObj (interp, listObjv[i+1], &want) == TCL_ERROR) {
error:
bson_destroy(mc->fieldsBson);
return TCL_ERROR;
bson_error:
return mongotcl_setBsonError (interp, mc->fieldsBson);
}

if (bson_append_int (mc->fieldsBson, key, want) != BSON_OK) {
Tcl_SetObjResult (interp, Tcl_NewStringObj ("bson error while generating field list", -1));
goto error;
goto bson_error;
}
}

if (bson_finish (mc->fieldsBson) != BSON_OK) {
goto bson_error;
}

mongo_cursor_set_fields (mc->cursor, mc->fieldsBson);

return TCL_OK;
}

Expand Down
3 changes: 3 additions & 0 deletions generic/mongotcl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ mongotcl_setMongoError (Tcl_Interp *interp, mongo *conn);
extern int
mongotcl_create_bson_command (Tcl_Interp *interp, char *commandName, CONST bson *bsonObj);

extern int
mongotcl_setBsonError (Tcl_Interp *interp, bson *bson);

extern int
mongotcl_createCursorObjCmd(Tcl_Interp *interp, mongo *conn, char *commandName, char *namespace); ;

Expand Down

0 comments on commit 61455a5

Please sign in to comment.