Skip to content

Commit

Permalink
Merge branch 'hotfix/universe-1.3.2' into prod
Browse files Browse the repository at this point in the history
  • Loading branch information
kuromukira committed Oct 11, 2022
2 parents 18ed91a + 3961f1e commit d9e0666
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<Version>1.3.1</Version>
<Version>1.3.2</Version>
14 changes: 7 additions & 7 deletions code/Universe/Galaxy.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net;
using System.Linq;
using System.Net;
using Universe.Options;
using Universe.Response;

Expand All @@ -25,23 +26,23 @@ protected Galaxy(Database db, string container, string partitionKey, bool record
private static QueryDefinition CreateQuery(IList<Catalyst> catalysts, ColumnOptions? columnOptions = null, IList<Sorting.Option> sorting = null, IList<string> groups = null)
{
// Column Options Builder
StringBuilder columnsBuilder = new("*");
string columnsInQuery = "*";
if (columnOptions is not null)
{
if (columnOptions?.Names is not null && columnOptions?.Names.Count > 0)
columnsBuilder.Append(string.Join(", ", columnOptions?.Names.Select(c => $"c.{c}").ToList()));
columnsInQuery = string.Join(", ", columnOptions?.Names.Select(c => $"c.{c}").ToList());

if ((columnOptions?.Top ?? 0) > 0)
columnsBuilder.Append($"TOP {columnOptions?.Top ?? 1} {columnsBuilder}");
columnsInQuery = $"TOP {columnOptions?.Top ?? 1} {columnsInQuery}";

if (columnOptions?.IsDistinct ?? false)
columnsBuilder.Append($"DISTINCT {columnsBuilder}");
columnsInQuery = $"DISTINCT {columnsInQuery}";

if (columnOptions?.Count ?? false)
{
groups ??= new List<string>();
groups = groups.Concat(columnOptions?.Names ?? new List<string>()).Distinct().ToList();
columnsBuilder.Append($"{columnsBuilder}, COUNT(1) Count");
columnsInQuery = $"{columnsInQuery}, COUNT(1) Count";
}
}

Expand All @@ -50,7 +51,6 @@ private static QueryDefinition CreateQuery(IList<Catalyst> catalysts, ColumnOpti
throw new UniverseException("ORDER BY is not supported in presence of GROUP BY");

// Update Columns Builder with Group By
string columnsInQuery = columnsBuilder.ToString();
if (columnsInQuery.Contains("*") && groups is not null && groups.Any())
columnsInQuery.Replace("*", string.Join(", ", groups.Select(c => $"c.{c}").ToList()));

Expand Down
6 changes: 3 additions & 3 deletions code/Universe/UniverseQuery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
<RepositoryType>Git</RepositoryType>
<Authors>Nor Gelera</Authors>
<Product>Universe</Product>
<Version>1.3.1</Version>
<Version>1.3.2</Version>
<PackageReleaseNotes>View release on https://github.com/kuromukira/universe/releases</PackageReleaseNotes>
<AssemblyVersion>1.3.1.0</AssemblyVersion>
<FileVersion>1.3.1.0</FileVersion>
<AssemblyVersion>1.3.2.0</AssemblyVersion>
<FileVersion>1.3.2.0</FileVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand Down
18 changes: 9 additions & 9 deletions code/Universe/UniverseQuery.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d9e0666

Please sign in to comment.