Fixed: Migrating case-sensitive Preferred Word REGEX to Custom Formats

Closes #2162
pull/2167/head
Qstick 2 years ago
parent 6f7c6721db
commit 71c2b1aeec

@ -360,6 +360,68 @@ namespace NzbDrone.Core.Test.Datastore.Migration
customFormats.First().FormatItems.First().Score.Should().Be(0);
}
[Test]
public void should_migrate_case_sensitive_regex()
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("ReleaseProfiles").Row(new
{
Preferred = new[]
{
new
{
Key = "/somestring/",
Value = 2
}
}.ToJson(),
Required = "[]",
Ignored = "[]",
Tags = "[]",
IncludePreferredWhenRenaming = true,
Enabled = true,
IndexerId = 0
});
});
var customFormats = db.Query<CustomFormat026>("SELECT \"Id\", \"Name\", \"IncludeCustomFormatWhenRenaming\", \"Specifications\" FROM \"CustomFormats\"");
customFormats.Should().HaveCount(1);
customFormats.First().Specifications.Should().HaveCount(1);
customFormats.First().Specifications.First().Body.Value.Should().Be("somestring");
}
[Test]
public void should_migrate_case_insensitive_regex()
{
var db = WithMigrationTestDb(c =>
{
c.Insert.IntoTable("ReleaseProfiles").Row(new
{
Preferred = new[]
{
new
{
Key = "/somestring/i",
Value = 2
}
}.ToJson(),
Required = "[]",
Ignored = "[]",
Tags = "[]",
IncludePreferredWhenRenaming = true,
Enabled = true,
IndexerId = 0
});
});
var customFormats = db.Query<CustomFormat026>("SELECT \"Id\", \"Name\", \"IncludeCustomFormatWhenRenaming\", \"Specifications\" FROM \"CustomFormats\"");
customFormats.Should().HaveCount(1);
customFormats.First().Specifications.Should().HaveCount(1);
customFormats.First().Specifications.First().Body.Value.Should().Be("somestring");
}
[Test]
public void should_migrate_naming_configs()
{

@ -148,7 +148,10 @@ namespace NzbDrone.Core.Datastore.Migration
foreach (var term in data)
{
var regexTerm = term.Key.TrimStart('/').TrimEnd("/i");
var regexTerm = term.Key
.TrimStart('/')
.TrimEnd('/')
.TrimEnd("/i");
// Validate Regex before creating a CF
try

Loading…
Cancel
Save