Fixed: SQL error searching for movie by name

This commit is contained in:
ta264 2020-05-14 21:37:35 +01:00 committed by Qstick
parent 32a6c9fe2a
commit 5c9b85972d
3 changed files with 14 additions and 3 deletions

View File

@ -169,6 +169,16 @@ namespace NzbDrone.Core.Test.Datastore
_subject.ToString().Should().Be($"((\"Movies\".\"CleanTitle\" = @Clause1_P1) AND (\"Movies\".\"Id\" IN (1, 2, 3)))");
}
[Test]
public void where_in_string_list()
{
var list = new List<string> { "first", "second", "third" };
_subject = Where(x => list.Contains(x.CleanTitle));
_subject.ToString().Should().Be($"(\"Movies\".\"CleanTitle\" IN @Clause1_P1)");
}
[Test]
public void enum_as_int()
{

View File

@ -275,7 +275,7 @@ namespace NzbDrone.Core.Datastore
{
var list = expression.Object;
if (list != null && (list.Type == typeof(string) || list.Type == typeof(List<string>)))
if (list != null && (list.Type == typeof(string)))
{
ParseStringContains(expression);
return;

View File

@ -101,8 +101,9 @@ namespace NzbDrone.Core.Movies
public List<Movie> FindByTitles(List<string> titles)
{
return Query(Builder().OrWhere<Movie>(x => titles.Contains(x.CleanTitle))
.OrWhere<AlternativeTitle>(x => titles.Contains(x.CleanTitle)));
var distinct = titles.Distinct().ToList();
return Query(Builder().OrWhere<Movie>(x => distinct.Contains(x.CleanTitle))
.OrWhere<AlternativeTitle>(x => distinct.Contains(x.CleanTitle)));
}
public List<Movie> FindByTitleInexact(string cleanTitle)