Skip to content

Commit

Permalink
fix: recursive problem when materialising ORM query
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinnee committed Nov 5, 2023
1 parent 832432f commit 8420d53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 7 additions & 5 deletions App/Modules/Cyan/Data/Repositories/PluginRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,18 +414,20 @@ public async Task<Result<IEnumerable<PluginVersionPrincipal>>> GetAllVersion(IEn

query = query.Where(predicate);

var pluginReferences = await query.ToArrayAsync();
this._logger.LogInformation("Plugin References: {@PluginReferences}", pluginReferences.Select(x => x.Id));
if (pluginReferences.Length != pluginRefs.Length)
var plugins = await query.Select(x => x.ToPrincipal()).ToArrayAsync();

this._logger.LogInformation("Plugin References: {@PluginReferences}", plugins.Select(x => x.Id));

if (plugins.Length != pluginRefs.Length)
{
var found = pluginReferences.Select(x => $"{x.Plugin.User.Username}/{x.Plugin.Name}:{x.Version}").ToArray();
var found = await query.Select(x => $"{x.Plugin.User.Username}/{x.Plugin.Name}:{x.Version}").ToArrayAsync();
var search = pluginRefs.Select(x => $"{x.Username}/{x.Name}:{x.Version}");
var notFound = search.Except(found);
return new MultipleEntityNotFound("Plugins not found", typeof(PluginPrincipal), notFound.ToArray(),
found.ToArray()).ToException();
}

return pluginReferences.Select(x => x.ToPrincipal()).ToResult();
return plugins;
}
catch (Exception e)
{
Expand Down
14 changes: 6 additions & 8 deletions App/Modules/Cyan/Data/Repositories/ProcessorRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,21 +420,19 @@ public async Task<Result<IEnumerable<ProcessorVersionPrincipal>>> GetAllVersion(

query = query.Where(predicate);

var processorReferences = await query.ToArrayAsync();
this._logger.LogInformation("Processor References: {@ProcessorReferences}",
processorReferences.Select(x => x.Id));
var processors = await query.Select(x => x.ToPrincipal()).ToArrayAsync();
this._logger.LogInformation("Processor References: {@ProcessorReferences}", processors.Select(x => x.Id));

if (processorReferences.Length != processorRefs.Length)
if (processors.Length != processorRefs.Length)
{
var found = processorReferences.Select(x => $"{x.Processor.User.Username}/{x.Processor.Name}:{x.Version}")
.ToArray();
var found = await query.Select(x => $"{x.Processor.User.Username}/{x.Processor.Name}:{x.Version}")
.ToArrayAsync();
var search = processorRefs.Select(x => $"{x.Username}/{x.Name}:{x.Version}");
var notFound = search.Except(found).ToArray();
return new MultipleEntityNotFound("Processors not found", typeof(ProcessorPrincipal), notFound, found)
.ToException();
}

return processorReferences.Select(x => x.ToPrincipal()).ToResult();
return processors;
}
catch (Exception e)
{
Expand Down

0 comments on commit 8420d53

Please sign in to comment.