Browse Source

Implemented CSHARP-254. Several return values that could potentially overflow Int32 have been changed to Int64.

pull/63/head
rstam 14 years ago
parent
commit
1031516348
  1. 4
      Driver/Core/CommandResults/GetLastErrorResult.cs
  2. 12
      Driver/Core/CommandResults/MapReduceResult.cs
  3. 6
      Driver/Core/MongoCollection.cs
  4. 8
      Driver/Core/MongoCursor.cs
  5. 6
      Driver/GridFS/MongoGridFSFileInfo.cs

4
Driver/Core/CommandResults/GetLastErrorResult.cs

@ -39,8 +39,8 @@ namespace MongoDB.Driver {
/// <summary>
/// Gets the number of documents affected.
/// </summary>
public int DocumentsAffected {
get { return response["n"].ToInt32(); }
public long DocumentsAffected {
get { return response["n"].ToInt64(); }
}
/// <summary>

12
Driver/Core/CommandResults/MapReduceResult.cs

@ -79,15 +79,15 @@ namespace MongoDB.Driver {
/// <summary>
/// Gets the emit count.
/// </summary>
public int EmitCount {
get { return response["counts"].AsBsonDocument["emit"].ToInt32(); }
public long EmitCount {
get { return response["counts"].AsBsonDocument["emit"].ToInt64(); }
}
/// <summary>
/// Gets the output count.
/// </summary>
public int OutputCount {
get { return response["counts"].AsBsonDocument["output"].ToInt32(); }
public long OutputCount {
get { return response["counts"].AsBsonDocument["output"].ToInt64(); }
}
/// <summary>
@ -100,8 +100,8 @@ namespace MongoDB.Driver {
/// <summary>
/// Gets the input count.
/// </summary>
public int InputCount {
get { return response["counts"].AsBsonDocument["input"].ToInt32(); }
public long InputCount {
get { return response["counts"].AsBsonDocument["input"].ToInt64(); }
}
#endregion

6
Driver/Core/MongoCollection.cs

@ -93,7 +93,7 @@ namespace MongoDB.Driver {
/// Counts the number of documents in this collection.
/// </summary>
/// <returns>The number of documents in this collection.</returns>
public virtual int Count() {
public virtual long Count() {
return Count(Query.Null);
}
@ -102,7 +102,7 @@ namespace MongoDB.Driver {
/// </summary>
/// <param name="query">The query (usually a QueryDocument or constructed using the Query builder).</param>
/// <returns>The number of documents in this collection that match the query.</returns>
public virtual int Count(
public virtual long Count(
IMongoQuery query
) {
var command = new CommandDocument {
@ -110,7 +110,7 @@ namespace MongoDB.Driver {
{ "query", BsonDocumentWrapper.Create(query) } // query is optional
};
var result = database.RunCommand(command);
return result.Response["n"].ToInt32();
return result.Response["n"].ToInt64();
}
/// <summary>

8
Driver/Core/MongoCursor.cs

@ -243,14 +243,14 @@ namespace MongoDB.Driver {
/// Returns the number of documents that match the query (ignores Skip and Limit, unlike Size which honors them).
/// </summary>
/// <returns>The number of documents that match the query.</returns>
public virtual int Count() {
public virtual long Count() {
isFrozen = true;
var command = new CommandDocument {
{ "count", collection.Name },
{ "query", BsonDocumentWrapper.Create(query) } // query is optional
};
var result = database.RunCommand(command);
return result.Response["n"].ToInt32();
return result.Response["n"].ToInt64();
}
/// <summary>
@ -548,7 +548,7 @@ namespace MongoDB.Driver {
/// Returns the size of the result set (honors Skip and Limit, unlike Count which does not).
/// </summary>
/// <returns>The size of the result set.</returns>
public virtual int Size() {
public virtual long Size() {
isFrozen = true;
var command = new CommandDocument {
{ "count", collection.Name },
@ -557,7 +557,7 @@ namespace MongoDB.Driver {
{ "skip", skip, skip != 0 }
};
var result = database.RunCommand(command);
return result.Response["n"].ToInt32();
return result.Response["n"].ToInt64();
}
#endregion

6
Driver/GridFS/MongoGridFSFileInfo.cs

@ -35,7 +35,7 @@ namespace MongoDB.Driver.GridFS {
private int chunkSize;
private string contentType;
private BsonValue id; // usually a BsonObjectId but not required to be
private int length;
private long length;
private string md5;
private BsonDocument metadata;
private string name;
@ -172,7 +172,7 @@ namespace MongoDB.Driver.GridFS {
/// <summary>
/// Gets the file lenth.
/// </summary>
public int Length {
public long Length {
get {
if (!cached) { Refresh(); }
return length;
@ -491,7 +491,7 @@ namespace MongoDB.Driver.GridFS {
}
exists = true;
id = fileInfo["_id"];
length = fileInfo["length"].ToInt32();
length = fileInfo["length"].ToInt64();
var md5Value = fileInfo["md5", null];
if (md5Value != null && !md5Value.IsBsonNull) {
md5 = md5Value.AsString;

Loading…
Cancel
Save