From c531fbddd5e71dcb591f3c5a50487dce028045ca Mon Sep 17 00:00:00 2001 From: Savorboard Date: Mon, 2 Oct 2017 21:00:49 +0800 Subject: [PATCH] fix postger sql bug. --- .../PostgreSqlMonitoringApi.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/DotNetCore.CAP.PostgreSql/PostgreSqlMonitoringApi.cs b/src/DotNetCore.CAP.PostgreSql/PostgreSqlMonitoringApi.cs index 0f9f469..76cd2d5 100644 --- a/src/DotNetCore.CAP.PostgreSql/PostgreSqlMonitoringApi.cs +++ b/src/DotNetCore.CAP.PostgreSql/PostgreSqlMonitoringApi.cs @@ -61,13 +61,13 @@ select count(""Id"") from ""{0}"".""received"" where ""StatusName"" in (N'Proce StringComparison.CurrentCultureIgnoreCase)) where += " and \"StatusName\" in (N'Processing',N'Scheduled',N'Enqueued')"; else - where += " and \"StatusName\" = @StatusName"; + where += " and Lower(\"StatusName\") = Lower(@StatusName)"; if (!string.IsNullOrEmpty(queryDto.Name)) - where += " and \"Name\" = @Name"; + where += " and Lower(\"Name\") = Lower(@Name)"; if (!string.IsNullOrEmpty(queryDto.Group)) - where += " and \"Group\" = @Group"; + where += " and Lower(\"Group\") = Lower(@Group)"; if (!string.IsNullOrEmpty(queryDto.Content)) - where += " and \"Content\" like '%@Content%'"; + where += " and \"Content\" ILike '%@Content%'"; var sqlQuery = $"select * from \"{_options.Schema}\".\"{tableName}\" where 1=1 {where} order by \"Added\" desc offset @Offset limit @Limit"; @@ -131,7 +131,7 @@ select count(""Id"") from ""{0}"".""received"" where ""StatusName"" in (N'Proce { var sqlQuery = statusName == StatusName.Processing ? $"select count(\"Id\") from \"{_options.Schema}\".\"{tableName}\" where \"StatusName\" in (N'Processing',N'Scheduled',N'Enqueued')" - : $"select count(\"Id\") from \"{_options.Schema}\".\"{tableName}\" where \"StatusName\" = @state"; + : $"select count(\"Id\") from \"{_options.Schema}\".\"{tableName}\" where Lower(\"StatusName\") = Lower(@state)"; var count = connection.ExecuteScalar(sqlQuery, new { state = statusName }); return count; @@ -174,7 +174,7 @@ with aggr as ( where ""StatusName"" = N'Processing' group by to_char(""Added"", 'yyyy-MM-dd-HH') ) -select ""Key"",""Count"" from aggr where ""Key""=Any(@keys);"; +select ""Key"",""Count"" from aggr where ""Key""= Any(@keys);"; var valuesMap = connection.Query(sqlQuery,new { keys = keyMaps.Keys.ToList(), statusName }) .ToList()