Single quotes around index column name won't die

This commit is contained in:
Mark McDowall 2014-02-05 23:39:28 -08:00
parent d648056bc4
commit 235bbc2d91
2 changed files with 3 additions and 4 deletions

View File

@ -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()
{

View File

@ -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;