Browse Source

Allow mixed case database names. Use more detailed error messages describing why a database name is invalid. [Patch submitted by Justin Dearing].

pull/1/head
Justin Dearing 15 years ago
committed by rstam
parent
commit
ed6a312500
  1. 2
      BsonLibrary/Properties/AssemblyInfo.cs
  2. 15
      CSharpDriver/Core/MongoDatabase.cs
  3. 2
      CSharpDriver/Properties/AssemblyInfo.cs

2
BsonLibrary/Properties/AssemblyInfo.cs

@ -47,4 +47,4 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.0.3936")]
[assembly: AssemblyVersion("0.5.0.*")]

15
CSharpDriver/Core/MongoDatabase.cs

@ -328,13 +328,14 @@ namespace MongoDB.CSharpDriver {
if (name == null) {
throw new ArgumentNullException("name");
}
if (
name == "" ||
name.IndexOfAny(new char[] { '\0', ' ', '.', '$', '/', '\\' }) != -1 ||
name != name.ToLower() ||
Encoding.UTF8.GetBytes(name).Length > 64
) {
throw new ArgumentException("Invalid database name", "name");
if (name == "") {
throw new ArgumentException("Database name is empty");
}
if (name.IndexOfAny(new char[] { '\0', ' ', '.', '$', '/', '\\' }) != -1) {
throw new ArgumentException("Database name cannot contain the following special characters: null, space, period, $, / or \\");
}
if (Encoding.UTF8.GetBytes(name).Length > 64) {
throw new ArgumentException("Database name cannot exceed 64 bytes (after encoding to UTF8)");
}
}
#endregion

2
CSharpDriver/Properties/AssemblyInfo.cs

@ -47,4 +47,4 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.0.3936")]
[assembly: AssemblyVersion("0.5.0.*")]
Loading…
Cancel
Save