Single quotes around index column name won't die

pull/4/head
Mark McDowall 11 years ago
parent d648056bc4
commit 235bbc2d91

@ -105,7 +105,6 @@ namespace NzbDrone.Core.Test.Datastore.SQLiteMigrationHelperTests
newIndexes.Select(c=>c.Column).Should().BeEquivalentTo(indexes.Select(c=>c.Column));
}
[Test]
public void should_be_able_to_create_table_with_new_indexes()
{

@ -29,7 +29,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
private static readonly Regex SchemaRegex = new Regex(@"['\""\[](?<name>\w+)['\""\]]\s(?<schema>[\w-\s]+)",
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline);
private static readonly Regex IndexRegex = new Regex(@"\(""(?<col>.*)""\s(?<direction>ASC|DESC)\)$",
private static readonly Regex IndexRegex = new Regex(@"\((?:""|')(?<col>.*)(?:""|')\s(?<direction>ASC|DESC)\)$",
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline);
public SqLiteMigrationHelper(IConnectionStringFactory connectionStringFactory, Logger logger)
@ -96,8 +96,6 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
var reader = command.ExecuteReader();
var sqls = ReadArray<string>(reader).ToList();
var indexes = new List<SQLiteIndex>();
foreach (var indexSql in sqls)
@ -105,6 +103,8 @@ namespace NzbDrone.Core.Datastore.Migration.Framework
var newIndex = new SQLiteIndex();
var matches = IndexRegex.Match(indexSql);
if (!matches.Success) continue;;
newIndex.Column = matches.Groups["col"].Value;
newIndex.Unique = indexSql.Contains("UNIQUE");
newIndex.Table = tableName;

Loading…
Cancel
Save