forked from litedb-org/LiteDB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for default name for indexes
- Loading branch information
Showing
3 changed files
with
53 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Reflection; | ||
using System.Text.RegularExpressions; | ||
using LiteDB.Engine; | ||
using System.Threading; | ||
using System.Linq.Expressions; | ||
|
||
namespace LiteDB.Tests.Engine | ||
{ | ||
[TestClass] | ||
public class Index_Tests | ||
{ | ||
[TestMethod] | ||
public void Index_With_No_Name() | ||
{ | ||
using (var db = new LiteEngine()) | ||
{ | ||
db.Insert("users", new BsonDocument { ["name"] = new BsonDocument { ["first"] = "John", ["last"] = "Doe" } }); | ||
db.Insert("users", new BsonDocument { ["name"] = new BsonDocument { ["first"] = "Marco", ["last"] = "Pollo" } }); | ||
|
||
// no index name defined | ||
db.EnsureIndex("users", "name.last"); | ||
db.EnsureIndex("users", "$.name.first", true); | ||
|
||
// default name: remove all non-[a-z] chars | ||
Assert.IsNotNull(db.Query("$indexes").Where("collection = 'users' AND name = 'namelast'").ExecuteScalar()); | ||
Assert.IsNotNull(db.Query("$indexes").Where("collection = 'users' AND name = 'namefirst'").ExecuteScalar()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters