Skip to content

Commit

Permalink
Moved condition parameter of Add to end so that name and value will c…
Browse files Browse the repository at this point in the history
…onsistently be the first two arguments.
  • Loading branch information
rstam committed Oct 15, 2010
1 parent c645758 commit a45bce5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
22 changes: 11 additions & 11 deletions BsonLibrary/ObjectModel/BsonDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,6 @@ string filename
#endregion

#region public methods
public BsonDocument Add(
bool condition,
string name,
BsonValue value
) {
if (condition) {
Add(name, value);
}
return this;
}

public BsonDocument Add(
BsonElement element
) {
Expand Down Expand Up @@ -314,6 +303,17 @@ BsonValue value
return this;
}

public BsonDocument Add(
string name,
BsonValue value,
bool condition
) {
if (condition) {
Add(name, value);
}
return this;
}

public void Clear() {
elements.Clear();
indexes.Clear();
Expand Down
2 changes: 1 addition & 1 deletion CSharpDriver/Core/MongoCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ bool returnNew
{ "sort", BsonDocumentWrapper.Create(sortBy) },
{ "update", BsonDocumentWrapper.Create(update) },
{ "fields", BsonDocumentWrapper.Create(fields) },
{ returnNew, "new", true }
{ "new", true, returnNew }
};
var result = database.RunCommand(command);
return result["value"].AsBsonDocument;
Expand Down
4 changes: 2 additions & 2 deletions CSharpDriver/Core/MongoCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ public int Size() {
var command = new BsonDocument {
{ "count", collection.Name },
{ "query", BsonDocumentWrapper.Create(query) }, // query is optional
{ limit != 0, "limit", limit },
{ skip != 0, "skip", skip }
{ "limit", limit, limit != 0 },
{ "skip", skip, skip != 0 }
};
var result = collection.Database.RunCommand(command);
return result["n"].ToInt32();
Expand Down
4 changes: 2 additions & 2 deletions CSharpDriver/Internal/MongoConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ SafeMode safeMode
if (safeMode.Enabled) {
var command = new BsonDocument {
{ "getlasterror", 1 }, // use all lowercase for backward compatibility
{ safeMode.Replications > 1, "w", safeMode.Replications },
{ safeMode.Replications > 1 && safeMode.Timeout != TimeSpan.Zero, "wtimeout", (int) safeMode.Timeout.TotalMilliseconds }
{ "w", safeMode.Replications, safeMode.Replications > 1 },
{ "wtimeout", (int) safeMode.Timeout.TotalMilliseconds, safeMode.Replications > 1 && safeMode.Timeout != TimeSpan.Zero }
};
using (
var getLastErrorMessage = new MongoQueryMessage<BsonDocument>(
Expand Down

0 comments on commit a45bce5

Please sign in to comment.