Skip to content

Commit

Permalink
EditTableDialog: Add '=' in fron of functions in default value
Browse files Browse the repository at this point in the history
When editing an existing table with a function used inside a default
value of a field add a '=' character before the default expression
string to match our own input format for these kind of default values.

See issue sqlitebrowser#166.
  • Loading branch information
MKleusberg committed May 18, 2015
1 parent a342194 commit 5578056
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/EditTableDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,15 @@ void EditTableDialog::populateFields()
tbitem->setCheckState(kPrimaryKey, f->primaryKey() ? Qt::Checked : Qt::Unchecked);
tbitem->setCheckState(kAutoIncrement, f->autoIncrement() ? Qt::Checked : Qt::Unchecked);
tbitem->setCheckState(kUnique, f->unique() ? Qt::Checked : Qt::Unchecked);
tbitem->setText(kDefault, f->defaultValue());

// For the default value check if it is surrounded by parantheses and if that's the case
// add a '=' character before the entire string to match the input format we're expecting
// from the user when using functions in the default value field.
if(f->defaultValue().startsWith('(') && f->defaultValue().endsWith(')'))
tbitem->setText(kDefault, "=" + f->defaultValue());
else
tbitem->setText(kDefault, f->defaultValue());

tbitem->setText(kCheck, f->check());
tbitem->setText(kForeignKey, f->foreignKey());
ui->treeWidget->addTopLevelItem(tbitem);
Expand Down

0 comments on commit 5578056

Please sign in to comment.