Fixed: SQL error searching for movie by name

pull/4436/head
ta264 5 years ago committed by Qstick
parent 32a6c9fe2a
commit 5c9b85972d

@ -169,6 +169,16 @@ namespace NzbDrone.Core.Test.Datastore
_subject.ToString().Should().Be($"((\"Movies\".\"CleanTitle\" = @Clause1_P1) AND (\"Movies\".\"Id\" IN (1, 2, 3)))"); _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] [Test]
public void enum_as_int() public void enum_as_int()
{ {

@ -275,7 +275,7 @@ namespace NzbDrone.Core.Datastore
{ {
var list = expression.Object; 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); ParseStringContains(expression);
return; return;

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

Loading…
Cancel
Save