Skip to content

Commit f591719

Browse files
authored
Backport of: Fix nested batch issue when initial command is within a pipeline (#402) (#412)
* Fix nested batch issue when initial command is within a pipeline (#402) fix nested batch issue when initial command is within a pipeline * fix test with compatible test context
1 parent 880324e commit f591719

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/NRedisStack/Pipeline.cs

+1
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

+16
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,20 @@ public void TestJsonPipeline()
157157
Assert.True(setResponse.Result);
158158
Assert.Equal("{\"Name\":\"Shachar\",\"Age\":23}", getResponse.Result.ToString());
159159
}
160+
161+
[SkipIfRedis(Is.OSSCluster)]
162+
public async void Issue401_TestPipelineAsInitialCommand()
163+
{
164+
IDatabase db = redisFixture.Redis.GetDatabase();
165+
166+
Auxiliary.ResetInfoDefaults(); // demonstrate first connection
167+
var pipeline = new Pipeline(db);
168+
169+
var setTask = pipeline.Json.SetAsync("json-key", "$", "{}");
170+
_ = pipeline.Db.KeyExpireAsync(key, TimeSpan.FromSeconds(10));
171+
172+
pipeline.Execute();
173+
174+
Assert.True(await setTask);
175+
}
160176
}

0 commit comments

Comments
 (0)