From 3961f1e21b8dbe6e795d878036c6234647666dc3 Mon Sep 17 00:00:00 2001 From: Nor Gelera Date: Tue, 11 Oct 2022 15:31:52 +0800 Subject: [PATCH] Fix issue with incorrect column options query syntax --- VERSION | 2 +- code/Universe/Galaxy.cs | 14 +++++++------- code/Universe/UniverseQuery.csproj | 6 +++--- code/Universe/UniverseQuery.xml | 18 +++++++++--------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/VERSION b/VERSION index da768e0..0c87a0e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.1 \ No newline at end of file +1.3.2 \ No newline at end of file diff --git a/code/Universe/Galaxy.cs b/code/Universe/Galaxy.cs index d4b18dc..85ce993 100644 --- a/code/Universe/Galaxy.cs +++ b/code/Universe/Galaxy.cs @@ -1,4 +1,5 @@ -using System.Net; +using System.Linq; +using System.Net; using Universe.Options; using Universe.Response; @@ -25,23 +26,23 @@ protected Galaxy(Database db, string container, string partitionKey, bool record private static QueryDefinition CreateQuery(IList catalysts, ColumnOptions? columnOptions = null, IList sorting = null, IList 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(); groups = groups.Concat(columnOptions?.Names ?? new List()).Distinct().ToList(); - columnsBuilder.Append($"{columnsBuilder}, COUNT(1) Count"); + columnsInQuery = $"{columnsInQuery}, COUNT(1) Count"; } } @@ -50,7 +51,6 @@ private static QueryDefinition CreateQuery(IList 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())); diff --git a/code/Universe/UniverseQuery.csproj b/code/Universe/UniverseQuery.csproj index 317c504..c863eb2 100644 --- a/code/Universe/UniverseQuery.csproj +++ b/code/Universe/UniverseQuery.csproj @@ -21,10 +21,10 @@ Git Nor Gelera Universe - 1.3.1 + 1.3.2 View release on https://github.com/kuromukira/universe/releases - 1.3.1.0 - 1.3.1.0 + 1.3.2.0 + 1.3.2.0 diff --git a/code/Universe/UniverseQuery.xml b/code/Universe/UniverseQuery.xml index fce892a..e0f953f 100644 --- a/code/Universe/UniverseQuery.xml +++ b/code/Universe/UniverseQuery.xml @@ -87,22 +87,22 @@ Get one model from the database - + Get a paginated list from the database - + Get a paginated list from the database - + Get a paginated list from the database - + List of column names to be part of the query Adds DISTINCT in the generated query @@ -112,7 +112,7 @@ will be added as part of the GROUP BY clause - + List of column names to be part of the query Adds DISTINCT in the generated query @@ -122,16 +122,16 @@ will be added as part of the GROUP BY clause - + List of column names to be part of the query - + Adds DISTINCT in the generated query - + Only select the specified number of top rows - + Count the number of rows. Please note that the column will be added as part of the GROUP BY clause