mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 05:00:19 -05:00
[PM-1524] Fix SQLite Collections (#2862)
* Use Client Side Execution for Sqlite * Run formatting * Remove Unused Record
This commit is contained in:
parent
09f86f23fe
commit
0e55862b3c
@ -304,8 +304,45 @@ public class CollectionRepository : Repository<Core.Entities.Collection, Collect
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
return await (from c in new UserCollectionDetailsQuery(userId).Run(dbContext)
|
||||
group c by new { c.Id, c.OrganizationId, c.Name, c.CreationDate, c.RevisionDate, c.ExternalId } into collectionGroup
|
||||
|
||||
var baseCollectionQuery = new UserCollectionDetailsQuery(userId).Run(dbContext);
|
||||
|
||||
if (dbContext.Database.IsSqlite())
|
||||
{
|
||||
return (await baseCollectionQuery.ToListAsync())
|
||||
.GroupBy(c => new
|
||||
{
|
||||
c.Id,
|
||||
c.OrganizationId,
|
||||
c.Name,
|
||||
c.CreationDate,
|
||||
c.RevisionDate,
|
||||
c.ExternalId
|
||||
})
|
||||
.Select(collectionGroup => new CollectionDetails
|
||||
{
|
||||
Id = collectionGroup.Key.Id,
|
||||
OrganizationId = collectionGroup.Key.OrganizationId,
|
||||
Name = collectionGroup.Key.Name,
|
||||
CreationDate = collectionGroup.Key.CreationDate,
|
||||
RevisionDate = collectionGroup.Key.RevisionDate,
|
||||
ExternalId = collectionGroup.Key.ExternalId,
|
||||
ReadOnly = Convert.ToBoolean(collectionGroup.Min(c => Convert.ToInt32(c.ReadOnly))),
|
||||
HidePasswords = Convert.ToBoolean(collectionGroup.Min(c => Convert.ToInt32(c.HidePasswords))),
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return await (from c in baseCollectionQuery
|
||||
group c by new
|
||||
{
|
||||
c.Id,
|
||||
c.OrganizationId,
|
||||
c.Name,
|
||||
c.CreationDate,
|
||||
c.RevisionDate,
|
||||
c.ExternalId
|
||||
} into collectionGroup
|
||||
select new CollectionDetails
|
||||
{
|
||||
Id = collectionGroup.Key.Id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user