1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-11 12:02:35 +02:00

Fixed: SqliteSchemaDumper with separate Primary Key clause

This commit is contained in:
ta264 2020-07-20 21:02:09 +01:00 committed by Qstick
parent 23349c1063
commit 539f495dbe
2 changed files with 8 additions and 2 deletions

View File

@ -25,6 +25,12 @@ public void Setup()
[TestCase(@"CREATE TABLE ""Test """"Table"" (""My""""Id"" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT)", "Test \"Table", "My\"Id")]
[TestCase(@"CREATE TABLE [Test Table] ([My Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT)", "Test Table", "My Id")]
[TestCase(@" CREATE TABLE `Test ``Table` ( `My`` Id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT ) ", "Test `Table", "My` Id")]
[TestCase(@"CREATE TABLE IF NOT EXISTS ""Test Table"" (
""MyId"" INTEGER NOT NULL,
PRIMARY KEY(""MyId"" AUTOINCREMENT)
);",
"Test Table",
"MyId")]
public void should_parse_table_language_flavors(string sql, string tableName, string columnName)
{
var result = Subject.ReadTableSchema(sql);

View File

@ -154,12 +154,12 @@ public TokenType Read()
{
var start = Index;
var end = start + 1;
while (end < Buffer.Length && (char.IsLetter(Buffer[end]) || char.IsNumber(Buffer[end]) || Buffer[end] == '_' || Buffer[end] == '('))
while (end < Buffer.Length && (char.IsLetter(Buffer[end]) || char.IsNumber(Buffer[end]) || Buffer[end] == '_'))
{
end++;
}
if (end >= Buffer.Length || Buffer[end] == ',' || Buffer[end] == ')' || char.IsWhiteSpace(Buffer[end]))
if (end >= Buffer.Length || Buffer[end] == ',' || Buffer[end] == ')' || Buffer[end] == '(' || char.IsWhiteSpace(Buffer[end]))
{
Index = end;
}