From 8a85977e1dd54668c74d9f18a76f1d842392c972 Mon Sep 17 00:00:00 2001 From: "agile.zhou" Date: Mon, 22 Dec 2025 22:18:29 +0800 Subject: [PATCH 1/2] fixbug: can not add item if the key exist different group --- .../ConfigService.cs | 4 +-- .../sqlite/ConfigServiceTests.cs | 32 ++++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/AgileConfig.Server.Service/ConfigService.cs b/src/AgileConfig.Server.Service/ConfigService.cs index 9ecbfcd7..92ce8a35 100644 --- a/src/AgileConfig.Server.Service/ConfigService.cs +++ b/src/AgileConfig.Server.Service/ConfigService.cs @@ -151,12 +151,12 @@ public async Task GetByAppIdKeyEnv(string appId, string group, string ke if (string.IsNullOrEmpty(group)) { Expression> exp1 = c => c.Group == "" || c.Group == null; - exp.And(exp1); + exp = exp.And(exp1); } else { Expression> exp1 = c => c.Group == group; - exp.And(exp1); + exp = exp.And(exp1); } using var repository = _configRepositoryAccessor(env); diff --git a/test/AgileConfig.Server.ServiceTests/sqlite/ConfigServiceTests.cs b/test/AgileConfig.Server.ServiceTests/sqlite/ConfigServiceTests.cs index e03ecb2e..3016fc7b 100644 --- a/test/AgileConfig.Server.ServiceTests/sqlite/ConfigServiceTests.cs +++ b/test/AgileConfig.Server.ServiceTests/sqlite/ConfigServiceTests.cs @@ -318,10 +318,9 @@ public async Task GetByAppIdKeyTest() ClearData(); var env = "DEV"; - var id = Guid.NewGuid().ToString(); var appid1 = Guid.NewGuid().ToString(); var appid2 = Guid.NewGuid().ToString(); - + var id = Guid.NewGuid().ToString(); var source = new Config { AppId = appid1, @@ -366,18 +365,43 @@ public async Task GetByAppIdKeyTest() OnlineStatus = OnlineStatus.Online, Env = env }; + var id3 = Guid.NewGuid().ToString(); + var source3 = new Config + { + AppId = appid1, + Id = id3, + Group = "", + Key = "k", + Value = "v", + Description = "d1", + CreateTime = DateTime.Now, + UpdateTime = DateTime.Now, + Status = ConfigStatus.Enabled, + OnlineStatus = OnlineStatus.Online, + Env = env + }; var result = await _service.AddAsync(source, env); Assert.IsTrue(result); var result1 = await _service.AddAsync(source1, env); Assert.IsTrue(result1); var result2 = await _service.AddAsync(source2, env); Assert.IsTrue(result2); + var result3 = await _service.AddAsync(source3, env); + Assert.IsTrue(result3); var config = await _service.GetByAppIdKeyEnv(appid1, "g", "k", env); Assert.IsNotNull(config); + Assert.AreEqual("g", config.Group); + Assert.AreEqual("k", config.Key); + Assert.AreEqual("v", config.Value); + var config1 = await _service.GetByAppIdKeyEnv(appid1, "", "k", env); + Assert.IsNotNull(config1); + Assert.AreEqual("", config1.Group); + Assert.AreEqual("k", config1.Key); + Assert.AreEqual("v", config1.Value); - var config1 = await _service.GetByAppIdKeyEnv(appid2, "g", "k", env); - Assert.IsNull(config1); + var config2 = await _service.GetByAppIdKeyEnv(appid2, "g", "k", env); + Assert.IsNull(config2); } [TestMethod] From c4473d460db58778bdfc8f6cc5f2a78e9fc9b9f7 Mon Sep 17 00:00:00 2001 From: "agile.zhou" Date: Mon, 22 Dec 2025 22:21:54 +0800 Subject: [PATCH 2/2] Update version no --- .../AgileConfig.Server.Apisite.csproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj b/src/AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj index 5d3ed223..68bcd731 100644 --- a/src/AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj +++ b/src/AgileConfig.Server.Apisite/AgileConfig.Server.Apisite.csproj @@ -3,11 +3,11 @@ net10.0 InProcess - 1.11.1 - 1.11.1 - 1.11.1 + 1.11.2 + 1.11.2 + 1.11.2 Linux - 1.11.1 + 1.11.2 kklldog kklldog