Fix primary key names not being escaped

See issue #613.
This commit is contained in:
Martin Kleusberg
2016-05-27 22:32:53 +02:00
parent 6622022ab6
commit 7e0adabd6a
2 changed files with 4 additions and 4 deletions

View File

@@ -222,7 +222,7 @@ QString Table::sql() const
{
if(f->primaryKey())
{
pk += f->name() + ",";
pk += escapeIdentifier(f->name()) + ",";
pks_found = true;
}
}

View File

@@ -22,7 +22,7 @@ void TestTable::sqlOutput()
"\t`id`\tinteger,\n"
"\t`car`\ttext,\n"
"\t`km`\tinteger CHECK(km > 1000),\n"
"\tPRIMARY KEY(id,km)\n"
"\tPRIMARY KEY(`id`,`km`)\n"
");"));
}
@@ -156,7 +156,7 @@ void TestTable::parseSQLMultiPk()
"\tid1 integer,\n"
"\tid2 integer,\n"
"\tnonpkfield blob,\n"
"PRIMARY KEY(id1,id2)\n"
"PRIMARY KEY(`id1`,`id2`)\n"
");";
Table tab = Table::parseSQL(sSQL).first;
@@ -219,7 +219,7 @@ void TestTable::parseNonASCIIChars()
{
QString sSQL = "CREATE TABLE `lösung` ("
"`Fieldöäüß` INTEGER,"
"PRIMARY KEY(Fieldöäüß)"
"PRIMARY KEY(`Fieldöäüß`)"
");";
Table tab = Table::parseSQL(sSQL).first;