1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-10 04:52:42 +01:00

SearchForSeries won't fail if an apostrophe is used in the search term (Let's PetaPoco handle building the query, as it should).

This commit is contained in:
Mark McDowall 2011-12-08 00:44:22 -08:00
parent 51958672d0
commit 58abb6fbc2
2 changed files with 29 additions and 4 deletions

View File

@ -721,5 +721,30 @@ public void SearchForSeries_should_not_return_results_that_do_not_contain_the_qu
//Assert
series.Should().HaveCount(0);
}
[Test]
public void SearchForSeries_should_return_results_when_query_has_special_characters()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var db = TestDbHelper.GetEmptyDatabase();
mocker.SetConstant(db);
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
.TheLast(1)
.With(s => s.Title = "It's Always Sunny")
.Build();
db.InsertMany(fakeSeries);
db.Insert(fakeQuality);
//Act
var series = mocker.Resolve<SeriesProvider>().SearchForSeries("it's");
//Assert
series.Should().HaveCount(1);
}
}
}

View File

@ -186,11 +186,11 @@ public virtual bool SeriesPathExists(string cleanPath)
public virtual List<Series> SearchForSeries(string title)
{
var query = String.Format(@"SELECT * FROM Series
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
WHERE Title LIKE '%{0}%'", title);
var query = String.Format("%{0}%", title);
var series = _database.Fetch<Series, QualityProfile>(query);
var series = _database.Fetch<Series, QualityProfile>(@"SELECT * FROM Series
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
WHERE Title LIKE @0", query);
return series;
}