mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user