diff options
| author | 2021-12-17 07:06:30 -0500 | |
|---|---|---|
| committer | 2021-12-17 07:06:30 -0500 | |
| commit | 1fdc150116cad39aae5c5da407c3312b47a59e3a (patch) | |
| tree | 123c79a4d7ad2d45781ba03ce939f7539fb428d8 /SQLiteStudio3/guiSQLiteStudio/constraints/columnprimarykeypanel.cpp | |
| parent | feda8a7db8d1d7c5439aa8f8feef7cc0dd2b59a0 (diff) | |
New upstream version 3.3.3+dfsg1.upstream/3.3.3+dfsg1
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/constraints/columnprimarykeypanel.cpp')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/constraints/columnprimarykeypanel.cpp | 23 |
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()); |
