Skip to content

Commit 2750d33

Browse files
committed
Fix nested batch issue when initial command is within a pipeline (redis#402)
fix nested batch issue when initial command is within a pipeline
1 parent 880324e commit 2750d33

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/NRedisStack/Pipeline.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class Pipeline
66
{
77
public Pipeline(IDatabase db)
88
{
9+
db.SetInfoInPipeline();
910
_batch = db.CreateBatch();
1011
}
1112

tests/NRedisStack.Tests/PipelineTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,22 @@ public void TestJsonPipeline()
157157
Assert.True(setResponse.Result);
158158
Assert.Equal("{\"Name\":\"Shachar\",\"Age\":23}", getResponse.Result.ToString());
159159
}
160+
161+
[SkippableTheory]
162+
[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))]
163+
[Obsolete]
164+
public async void Issue401_TestPipelineAsInitialCommand(string endpointId)
165+
{
166+
IDatabase db = GetCleanDatabase(endpointId);
167+
168+
Auxiliary.ResetInfoDefaults(); // demonstrate first connection
169+
var pipeline = new Pipeline(db);
170+
171+
var setTask = pipeline.Json.SetAsync("json-key", "$", "{}");
172+
_ = pipeline.Db.KeyExpireAsync(key, TimeSpan.FromSeconds(10));
173+
174+
pipeline.Execute();
175+
176+
Assert.True(await setTask);
177+
}
160178
}

0 commit comments

Comments
 (0)