Skip to content

Commit 042e919

Browse files
committed
Fixed bug when running IN-query on strings with InMemoryAdapter
1 parent 35e2e06 commit 042e919

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

Simple.Data.InMemoryTest/InMemoryTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ public void InsertAndFindAllShouldWork()
4949
Assert.AreEqual("Alice", record.Name);
5050
}
5151

52+
[Test]
53+
public void InsertAndFindAllByStringTypeShouldWork()
54+
{
55+
Database.UseMockAdapter(new InMemoryAdapter());
56+
var db = Database.Open();
57+
db.Test.Insert(Id: 1, Name: "Alice");
58+
db.Test.Insert(Id: 2, Name: "Bob");
59+
List<dynamic> records = db.Test.FindAllByName(new[] { "Alice", "Bob" }).ToList();
60+
Assert.IsNotNull(records);
61+
Assert.AreEqual(2, records.Count);
62+
}
63+
5264
[Test]
5365
public void InsertAndFindWithTwoColumnsShouldWork()
5466
{

Simple.Data/QueryPolyfills/WhereClauseHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private Func<IDictionary<string, object>, bool> EqualExpressionToWhereClause(Sim
100100
d =>
101101
{
102102
var resolvedLeftOperand = Resolve(d, arg.LeftOperand);
103-
if (resolvedLeftOperand.OfType<IEnumerable>().Any())
103+
if (resolvedLeftOperand.Any(o => !(o is string) && o is IEnumerable))
104104
{
105105
return resolvedLeftOperand.OfType<IEnumerable>().Any(
106106
o => o.Cast<object>().SequenceEqual(((IEnumerable)arg.RightOperand).Cast<object>()));

0 commit comments

Comments
 (0)