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.
Merge pull request litedb-org#2498 from JKamsker/bugs/fix-2487-allow-…
…contains-whitespaces Bugs/fix 2487 allow contains whitespaces
- Loading branch information
Showing
5 changed files
with
63 additions
and
12 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,45 @@ | ||
using FluentAssertions; | ||
|
||
using System.Diagnostics; | ||
|
||
using Xunit; | ||
|
||
namespace LiteDB.Tests.Issues; | ||
|
||
public class Issue2487_tests | ||
{ | ||
private class DataClass | ||
{ | ||
[BsonId] | ||
public int Id { get; set; } | ||
|
||
public string Foo { get; set; } | ||
|
||
public string Bar { get; set; } | ||
} | ||
|
||
[Fact] | ||
public void Test_Contains_EmptyStrings() | ||
{ | ||
using var engine = new ConnectionString(":memory:").CreateEngine(); | ||
|
||
using var db = new LiteDatabase(engine); | ||
var collection = db.GetCollection<DataClass>("data"); | ||
|
||
collection.Insert(new DataClass { Foo = "bar", Bar = "abc" }); | ||
collection.Insert(new DataClass { Foo = " ", Bar = "def" }); | ||
collection.Insert(new DataClass { Foo = "fo bar", Bar = "def" }); | ||
collection.Insert(new DataClass { Foo = "", Bar = "def" }); | ||
collection.Insert(new DataClass { Foo = null, Bar = "def" }); | ||
|
||
var containsAction = () => collection.FindOne(x => x.Foo.Contains(" ")); | ||
containsAction.Should().NotThrow(); | ||
|
||
var def = containsAction(); | ||
def.Should().NotBeNull(); | ||
def.Bar.Should().Be("def"); | ||
|
||
var shouldExecute = () => engine.Query("data", Query.All(Query.Contains("Foo", " "))); | ||
shouldExecute.Should().NotThrow(); | ||
} | ||
} |
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
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