aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/constraints/columnprimarykeypanel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/constraints/columnprimarykeypanel.cpp')
-rw-r--r--SQLiteStudio3/guiSQLiteStudio/constraints/columnprimarykeypanel.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/constraints/columnprimarykeypanel.cpp b/SQLiteStudio3/guiSQLiteStudio/constraints/columnprimarykeypanel.cpp
index f8975d8..fa7b7c3 100644
--- a/SQLiteStudio3/guiSQLiteStudio/constraints/columnprimarykeypanel.cpp
+++ b/SQLiteStudio3/guiSQLiteStudio/constraints/columnprimarykeypanel.cpp
@@ -39,6 +39,9 @@ void ColumnPrimaryKeyPanel::init()
connect(ui->namedCheck, SIGNAL(toggled(bool)), this, SIGNAL(updateValidation()));
connect(ui->namedEdit, SIGNAL(textChanged(QString)), this, SIGNAL(updateValidation()));
+ connect(ui->sortOrderCheck, SIGNAL(toggled(bool)), this, SIGNAL(updateValidation()));
+ connect(ui->sortOrderCombo, SIGNAL(currentTextChanged(QString)), this, SIGNAL(updateValidation()));
+ connect(ui->autoIncrCheck, SIGNAL(toggled(bool)), this, SIGNAL(updateValidation()));
connect(ui->sortOrderCheck, SIGNAL(toggled(bool)), this, SLOT(updateState()));
connect(ui->namedCheck, SIGNAL(toggled(bool)), this, SLOT(updateState()));
connect(ui->conflictCheck, SIGNAL(toggled(bool)), this, SLOT(updateState()));
@@ -48,8 +51,7 @@ void ColumnPrimaryKeyPanel::init()
void ColumnPrimaryKeyPanel::readConstraint()
{
SqliteCreateTable::Column::Constraint* constr = dynamic_cast<SqliteCreateTable::Column::Constraint*>(constraint.data());
- if (constraint->dialect == Dialect::Sqlite3)
- ui->autoIncrCheck->setChecked(constr->autoincrKw);
+ ui->autoIncrCheck->setChecked(constr->autoincrKw);
if (constr->sortOrder != SqliteSortOrder::null)
{
@@ -77,7 +79,6 @@ void ColumnPrimaryKeyPanel::updateState()
ui->conflictCombo->setEnabled(ui->conflictCheck->isChecked());
}
-
bool ColumnPrimaryKeyPanel::validate()
{
bool nameOk = true;
@@ -86,7 +87,16 @@ bool ColumnPrimaryKeyPanel::validate()
setValidState(ui->namedEdit, nameOk, tr("Enter a name of the constraint."));
- return nameOk;
+ bool sortOk = true;
+ if (ui->autoIncrCheck->isChecked() && ui->sortOrderCombo->isEnabled() &&
+ ui->sortOrderCombo->currentText().toUpper() == "DESC")
+ {
+ sortOk = false;
+ }
+
+ setValidState(ui->sortOrderCombo, sortOk, tr("Descending order is not allowed with AUTOINCREMENT."));
+
+ return nameOk && sortOk;
}
void ColumnPrimaryKeyPanel::constraintAvailable()
@@ -94,8 +104,6 @@ void ColumnPrimaryKeyPanel::constraintAvailable()
if (constraint.isNull())
return;
- ui->autoIncrCheck->setVisible(constraint->dialect == Dialect::Sqlite3);
-
readConstraint();
}
@@ -107,8 +115,7 @@ void ColumnPrimaryKeyPanel::storeConfiguration()
SqliteCreateTable::Column::Constraint* constr = dynamic_cast<SqliteCreateTable::Column::Constraint*>(constraint.data());
constr->type = SqliteCreateTable::Column::Constraint::PRIMARY_KEY;
- if (constraint->dialect == Dialect::Sqlite3)
- constr->autoincrKw = ui->autoIncrCheck->isChecked();
+ constr->autoincrKw = ui->autoIncrCheck->isChecked();
if (ui->sortOrderCheck->isChecked() && ui->sortOrderCombo->currentIndex() > -1)
constr->sortOrder = sqliteSortOrder(ui->sortOrderCombo->currentText());