Fix: Feature values are not cleared entirely in database

resolves https://github.com/abpframework/abp/issues/4289
pull/4290/head
Yunus Emre Kalkan 5 years ago
parent 70a95cf594
commit b5915801de

@ -44,8 +44,8 @@ namespace Volo.Abp.FeatureManagement
public virtual async Task DeleteAsync(string name, string providerName, string providerKey) public virtual async Task DeleteAsync(string name, string providerName, string providerKey)
{ {
var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey); var featureValues = await FeatureValueRepository.FindAllAsync(name, providerName, providerKey);
if (featureValue != null) foreach (var featureValue in featureValues)
{ {
await FeatureValueRepository.DeleteAsync(featureValue); await FeatureValueRepository.DeleteAsync(featureValue);
} }
@ -78,4 +78,4 @@ namespace Volo.Abp.FeatureManagement
return FeatureValueCacheItem.CalculateCacheKey(name, providerName, providerKey); return FeatureValueCacheItem.CalculateCacheKey(name, providerName, providerKey);
} }
} }
} }

@ -183,4 +183,4 @@ namespace Volo.Abp.FeatureManagement
return value; return value;
} }
} }
} }

@ -9,6 +9,8 @@ namespace Volo.Abp.FeatureManagement
{ {
Task<FeatureValue> FindAsync(string name, string providerName, string providerKey); Task<FeatureValue> FindAsync(string name, string providerName, string providerKey);
Task<List<FeatureValue>> FindAllAsync(string name, string providerName, string providerKey);
Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey); Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey);
} }
} }

@ -23,6 +23,14 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore
); );
} }
public async Task<List<FeatureValue>> FindAllAsync(string name, string providerName, string providerKey)
{
return await DbSet
.Where(
s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey
).ToListAsync();
}
public virtual async Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey) public virtual async Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey)
{ {
return await DbSet return await DbSet
@ -31,4 +39,4 @@ namespace Volo.Abp.FeatureManagement.EntityFrameworkCore
).ToListAsync(); ).ToListAsync();
} }
} }
} }

@ -22,6 +22,12 @@ namespace Volo.Abp.FeatureManagement.MongoDB
.FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey); .FirstOrDefaultAsync(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey);
} }
public async Task<List<FeatureValue>> FindAllAsync(string name, string providerName, string providerKey)
{
return await GetMongoQueryable()
.Where(s => s.Name == name && s.ProviderName == providerName && s.ProviderKey == providerKey).ToListAsync();
}
public virtual async Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey) public virtual async Task<List<FeatureValue>> GetListAsync(string providerName, string providerKey)
{ {
return await GetMongoQueryable() return await GetMongoQueryable()
@ -29,4 +35,4 @@ namespace Volo.Abp.FeatureManagement.MongoDB
.ToListAsync(); .ToListAsync();
} }
} }
} }

@ -40,6 +40,18 @@ namespace Volo.Abp.FeatureManagement
featureValue.ShouldBeNull(); featureValue.ShouldBeNull();
} }
[Fact]
public async Task FindAAllsync()
{
var featureValues = await Repository.FindAllAsync(
TestFeatureDefinitionProvider.ProjectCount,
EditionFeatureValueProvider.ProviderName,
TestEditionIds.Enterprise.ToString()
);
featureValues.Count.ShouldBe(1);
}
[Fact] [Fact]
public async Task GetListAsync() public async Task GetListAsync()
{ {

Loading…
Cancel
Save