From c3782806e572d8fa8550a51f1a60d542fadfe82e Mon Sep 17 00:00:00 2001 From: Alexandre Bernard Date: Tue, 17 Sep 2024 14:03:26 +0200 Subject: [PATCH 1/2] failing test Signed-off-by: Alexandre Bernard --- tests/Dapper.Tests/AsyncTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/Dapper.Tests/AsyncTests.cs b/tests/Dapper.Tests/AsyncTests.cs index 7a9abf2d1..c4c8db992 100644 --- a/tests/Dapper.Tests/AsyncTests.cs +++ b/tests/Dapper.Tests/AsyncTests.cs @@ -995,5 +995,23 @@ public void AssertNoCacheWorksForQueryMultiple() Assert.Equal(123, c); Assert.Equal(456, d); } + + [Fact] + public async Task AssertNoCacheWorksForMultiMap() + { + const int a = 123, b = 456; + var cmdDef = new CommandDefinition("select @a as a, @b as b;", new + { + a, + b + }, commandType: CommandType.Text, flags: CommandFlags.NoCache | CommandFlags.Buffered); + + SqlMapper.PurgeQueryCache(); + var before = SqlMapper.GetCachedSQLCount(); + Assert.Equal(0, before); + + await MarsConnection.QueryAsync(cmdDef, splitOn: "b", map: (a, b) => (a, b)); + Assert.Equal(0, SqlMapper.GetCachedSQLCount()); + } } } From b5c70d567b816d3767bad17d3c4267f89b3f35ac Mon Sep 17 00:00:00 2001 From: Alexandre Bernard Date: Tue, 17 Sep 2024 14:10:18 +0200 Subject: [PATCH 2/2] add succesful test for comparison Signed-off-by: Alexandre Bernard --- tests/Dapper.Tests/AsyncTests.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/Dapper.Tests/AsyncTests.cs b/tests/Dapper.Tests/AsyncTests.cs index c4c8db992..0bb54ee05 100644 --- a/tests/Dapper.Tests/AsyncTests.cs +++ b/tests/Dapper.Tests/AsyncTests.cs @@ -1013,5 +1013,24 @@ public async Task AssertNoCacheWorksForMultiMap() await MarsConnection.QueryAsync(cmdDef, splitOn: "b", map: (a, b) => (a, b)); Assert.Equal(0, SqlMapper.GetCachedSQLCount()); } + + + [Fact] + public async Task AssertNoCacheWorksForQueryAsync() + { + const int a = 123, b = 456; + var cmdDef = new CommandDefinition("select @a as a, @b as b;", new + { + a, + b + }, commandType: CommandType.Text, flags: CommandFlags.NoCache | CommandFlags.Buffered); + + SqlMapper.PurgeQueryCache(); + var before = SqlMapper.GetCachedSQLCount(); + Assert.Equal(0, before); + + await MarsConnection.QueryAsync<(int, int)>(cmdDef); + Assert.Equal(0, SqlMapper.GetCachedSQLCount()); + } } }