Skip to content

Commit 3c429ae

Browse files
authored
Merge branch 'master' into dependabot/nuget/xunit.runner.visualstudio-2.8.2
2 parents 60f2070 + dfc75d2 commit 3c429ae

File tree

4 files changed

+57
-5
lines changed

4 files changed

+57
-5
lines changed

src/NRedisStack/Search/Document.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public static Document Load(string id, double score, byte[]? payload, RedisValue
3131
{
3232
Document ret = new Document(id, score, payload);
3333
if (fields == null) return ret;
34+
if (fields.Length == 1 && fields[0].IsNull)
35+
{
36+
return ret;
37+
}
3438
for (int i = 0; i < fields.Length; i += 2)
3539
{
3640
string fieldName = fields[i]!;

tests/Doc/Doc.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
<PrivateAssets>all</PrivateAssets>
1616
</PackageReference>
17-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
1818
<PackageReference Include="xunit" Version="2.4.2" />
1919
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
2020
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -26,4 +26,4 @@
2626
<ProjectReference Include="..\..\src\NRedisStack\NRedisStack.csproj" />
2727
<ProjectReference Include="..\..\tests\NRedisStack.Tests\NRedisStack.Tests.csproj" />
2828
</ItemGroup>
29-
</Project>
29+
</Project>

tests/NRedisStack.Tests/NRedisStack.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
<PrivateAssets>all</PrivateAssets>
2121
</PackageReference>
2222
<PackageReference Include="dotenv.net" Version="3.1.3" />
23+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
2324
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1">
2425
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2526
<PrivateAssets>all</PrivateAssets>
2627
</PackageReference>
27-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
2828
<PackageReference Include="NetTopologySuite" Version="2.5.0" />
2929
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
3030
<PackageReference Include="StackExchange.Redis" Version="2.8.16" />
3131
<PackageReference Include="xunit" Version="2.4.1" />
3232
<PackageReference Include="xunit.assert" Version="2.4.1" />
33-
<PackageReference Include="BouncyCastle.Cryptography" Version="2.2.0" />
33+
<PackageReference Include="BouncyCastle.Cryptography" Version="2.3.1" />
3434
<PackageReference Include="Microsoft.Azure.StackExchangeRedis" Version="3.1.0" />
3535
</ItemGroup>
3636

tests/NRedisStack.Tests/Search/SearchTests.cs

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212

1313
namespace NRedisStack.Tests.Search;
14-
1514
public class SearchTests : AbstractNRedisStackTest, IDisposable
1615
{
1716
// private readonly string key = "SEARCH_TESTS";
@@ -3313,4 +3312,53 @@ public void TestNumericLogicalOperatorsInDialect4()
33133312
Assert.Equal(1, ft.Search(index, new Query("@version:[123 123] | @id:[456 7890]")).TotalResults);
33143313
Assert.Equal(1, ft.Search(index, new Query("@version==123 @id==456").Dialect(4)).TotalResults);
33153314
}
3315+
3316+
[Fact]
3317+
public void TestDocumentLoad_Issue352()
3318+
{
3319+
Document d = Document.Load("1", 0.5, null, new RedisValue[] { RedisValue.Null });
3320+
Assert.Empty(d.GetProperties().ToList());
3321+
}
3322+
3323+
[SkipIfRedis(Is.OSSCluster)]
3324+
public void TestDocumentLoadWithDB_Issue352()
3325+
{
3326+
IDatabase db = redisFixture.Redis.GetDatabase();
3327+
db.Execute("FLUSHALL");
3328+
var ft = db.FT();
3329+
3330+
Schema sc = new Schema().AddTextField("first", 1.0).AddTextField("last", 1.0).AddNumericField("age");
3331+
Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc));
3332+
3333+
Document droppedDocument = null;
3334+
int numberOfAttempts = 0;
3335+
do
3336+
{
3337+
db.HashSet("student:1111", new HashEntry[] { new("first", "Joe"), new("last", "Dod"), new("age", 18) });
3338+
3339+
Assert.True(db.KeyExpire("student:1111", TimeSpan.FromMilliseconds(500)));
3340+
3341+
Boolean cancelled = false;
3342+
Task searchTask = Task.Run(() =>
3343+
{
3344+
for (int i = 0; i < 100000; i++)
3345+
{
3346+
SearchResult result = ft.Search(index, new Query());
3347+
List<Document> docs = result.Documents;
3348+
if (docs.Count == 0 || cancelled)
3349+
{
3350+
break;
3351+
}
3352+
else if (docs[0].GetProperties().ToList().Count == 0)
3353+
{
3354+
droppedDocument = docs[0];
3355+
}
3356+
}
3357+
});
3358+
Task.WhenAny(searchTask, Task.Delay(1000)).GetAwaiter().GetResult();
3359+
Assert.True(searchTask.IsCompleted);
3360+
Assert.Null(searchTask.Exception);
3361+
cancelled = true;
3362+
} while (droppedDocument == null && numberOfAttempts++ < 3);
3363+
}
33163364
}

0 commit comments

Comments
 (0)