Fix removal of primary keys when editing tables

Suppose you have this table:

CREATE TABLE `test` (
	`a`	INTEGER PRIMARY KEY AUTOINCREMENT,
	`b`	INTEGER
);

Editing this and removing the primary key would lead to this table
statement:

CREATE TABLE `test` (
        `a`     INTEGER,
        `b`     INTEGER,
        PRIMARY KEY()
);

This is fixed by this commit, the invalid empty primary key line isn't
outputted anymore.
This commit is contained in:
Martin Kleusberg
2017-01-04 18:13:47 +01:00
parent f7a29ff541
commit 31f73df721

View File

@@ -295,7 +295,7 @@ QString Table::sql() const
bool autoincrement = hasAutoIncrement();
while(it != m_constraints.constEnd())
{
if(!autoincrement || it.value()->type() != Constraint::PrimaryKeyConstraintType)
if((!autoincrement || it.value()->type() != Constraint::PrimaryKeyConstraintType) && !it.key().isEmpty())
{
sql += QString(",\n\t");
sql += it.value()->toSql(it.key());