Backport pull request #15381 from jellyfin/release-10.11.z

Fix name filters to use only SortName

Original-merge: 7222910b05dff772fad22d4f557fad20578fa275

Merged-by: crobibero <cody@robibe.ro>

Backported-by: Bond_009 <bond.009@outlook.com>
This commit is contained in:
theguymadmax 2025-11-17 14:08:51 -05:00 committed by Bond_009
parent 7d05c875f3
commit bcec5f2e44

View File

@ -1944,19 +1944,20 @@ public sealed class BaseItemRepository
if (!string.IsNullOrWhiteSpace(filter.NameStartsWith)) if (!string.IsNullOrWhiteSpace(filter.NameStartsWith))
{ {
baseQuery = baseQuery.Where(e => e.SortName!.StartsWith(filter.NameStartsWith)); var startsWithLower = filter.NameStartsWith.ToLowerInvariant();
baseQuery = baseQuery.Where(e => e.SortName!.StartsWith(startsWithLower));
} }
if (!string.IsNullOrWhiteSpace(filter.NameStartsWithOrGreater)) if (!string.IsNullOrWhiteSpace(filter.NameStartsWithOrGreater))
{ {
// i hate this var startsOrGreaterLower = filter.NameStartsWithOrGreater.ToLowerInvariant();
baseQuery = baseQuery.Where(e => e.SortName!.FirstOrDefault() > filter.NameStartsWithOrGreater[0] || e.Name!.FirstOrDefault() > filter.NameStartsWithOrGreater[0]); baseQuery = baseQuery.Where(e => e.SortName!.CompareTo(startsOrGreaterLower) >= 0);
} }
if (!string.IsNullOrWhiteSpace(filter.NameLessThan)) if (!string.IsNullOrWhiteSpace(filter.NameLessThan))
{ {
// i hate this var lessThanLower = filter.NameLessThan.ToLowerInvariant();
baseQuery = baseQuery.Where(e => e.SortName!.FirstOrDefault() < filter.NameLessThan[0] || e.Name!.FirstOrDefault() < filter.NameLessThan[0]); baseQuery = baseQuery.Where(e => e.SortName!.CompareTo(lessThanLower ) < 0);
} }
if (filter.ImageTypes.Length > 0) if (filter.ImageTypes.Length > 0)