mirror of
https://github.com/Radarr/Radarr.git
synced 2024-10-05 15:47:20 +02:00
Maintain PrimaryKey and AutoIncrement on some schemas
[common]
This commit is contained in:
parent
4f5f9ff77e
commit
ec86de78d2
@ -1,4 +1,4 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@ -38,6 +38,7 @@ public void should_parse_table_language_flavors(string sql, string tableName, st
|
|||||||
result.Name.Should().Be(tableName);
|
result.Name.Should().Be(tableName);
|
||||||
result.Columns.Count.Should().Be(1);
|
result.Columns.Count.Should().Be(1);
|
||||||
result.Columns.First().Name.Should().Be(columnName);
|
result.Columns.First().Name.Should().Be(columnName);
|
||||||
|
result.Columns.First().IsIdentity.Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(@"CREATE INDEX TestIndex ON TestTable (MyId)", "TestIndex", "TestTable", "MyId")]
|
[TestCase(@"CREATE INDEX TestIndex ON TestTable (MyId)", "TestIndex", "TestTable", "MyId")]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
using FluentMigrator.Model;
|
using FluentMigrator.Model;
|
||||||
using FluentMigrator.Runner.Processors.SQLite;
|
using FluentMigrator.Runner.Processors.SQLite;
|
||||||
|
|
||||||
@ -66,6 +67,24 @@ protected virtual TableDefinition ParseCreateTableStatement(SqliteSyntaxReader r
|
|||||||
|
|
||||||
if (columnReader.Read() == SqliteSyntaxReader.TokenType.StringToken)
|
if (columnReader.Read() == SqliteSyntaxReader.TokenType.StringToken)
|
||||||
{
|
{
|
||||||
|
if (columnReader.ValueToUpper == "PRIMARY")
|
||||||
|
{
|
||||||
|
columnReader.SkipTillToken(SqliteSyntaxReader.TokenType.ListStart);
|
||||||
|
if (columnReader.Read() == SqliteSyntaxReader.TokenType.Identifier)
|
||||||
|
{
|
||||||
|
var pk = table.Columns.First(v => v.Name == columnReader.Value);
|
||||||
|
pk.IsPrimaryKey = true;
|
||||||
|
pk.IsNullable = true;
|
||||||
|
pk.IsUnique = true;
|
||||||
|
if (columnReader.Buffer.ToUpperInvariant().Contains("AUTOINCREMENT"))
|
||||||
|
{
|
||||||
|
pk.IsIdentity = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (columnReader.ValueToUpper == "CONSTRAINT" ||
|
if (columnReader.ValueToUpper == "CONSTRAINT" ||
|
||||||
columnReader.ValueToUpper == "PRIMARY" || columnReader.ValueToUpper == "UNIQUE" ||
|
columnReader.ValueToUpper == "PRIMARY" || columnReader.ValueToUpper == "UNIQUE" ||
|
||||||
columnReader.ValueToUpper == "CHECK" || columnReader.ValueToUpper == "FOREIGN")
|
columnReader.ValueToUpper == "CHECK" || columnReader.ValueToUpper == "FOREIGN")
|
||||||
|
Loading…
Reference in New Issue
Block a user