Fixed: Use titlecase when querying DB with sort keys

Fixes #3301
This commit is contained in:
Qstick 2023-01-21 12:01:39 -06:00
commit 35e14eab72

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Core.Datastore namespace NzbDrone.Core.Datastore
{ {
@ -100,7 +101,7 @@ namespace NzbDrone.Core.Datastore
var split = sortKey.Split('.'); var split = sortKey.Split('.');
if (split.Length != 2) if (split.Length != 2)
{ {
return sortKey; return sortKey.FirstCharToUpper();
} }
table = split[0]; table = split[0];
@ -109,12 +110,12 @@ namespace NzbDrone.Core.Datastore
if (table != null && !TableMap.Values.Contains(table, StringComparer.OrdinalIgnoreCase)) if (table != null && !TableMap.Values.Contains(table, StringComparer.OrdinalIgnoreCase))
{ {
return sortKey; return sortKey.FirstCharToUpper();
} }
if (!_allowedOrderBy.Contains(sortKey)) if (!_allowedOrderBy.Contains(sortKey))
{ {
return sortKey; return sortKey.FirstCharToUpper();
} }
return _allowedOrderBy.First(x => x.Equals(sortKey, StringComparison.OrdinalIgnoreCase)); return _allowedOrderBy.First(x => x.Equals(sortKey, StringComparison.OrdinalIgnoreCase));