From 3a85d96a6dc19bbf5885f8364e79b8e3646cc462 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Mon, 3 Jun 2013 18:26:46 +0200 Subject: [PATCH] DBBrowserDB: When reading DB layout also save not null and default value Fix the updateSchemea() method to also read and save the not null flag and the default value of each column. This fixes a problem in renameColumn() which made it "forget" these values. It is now possible to set the not null flag of multiple columns in EditTableDialog. --- src/sqlitedb.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 8e0d65da..16285fe8 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -866,14 +866,15 @@ void DBBrowserDB::updateSchema( ) while ( sqlite3_step(vm) == SQLITE_ROW ){ if (sqlite3_column_count(vm)==6) { - int ispk= 0; - QString val1 = QString::fromUtf8((const char *) sqlite3_column_text(vm, 1)); - QString val2 = QString::fromUtf8((const char *) sqlite3_column_text(vm, 2)); - ispk = sqlite3_column_int(vm, 5); - if(ispk==1) - val2.append(QString(" PRIMARY KEY")); + QString val_name = QString::fromUtf8((const char *)sqlite3_column_text(vm, 1)); + QString val_type = QString::fromUtf8((const char *)sqlite3_column_text(vm, 2)); + bool val_nn = sqlite3_column_int(vm, 3) == 1; + QString val_default = QString::fromUtf8((const char *)sqlite3_column_text(vm, 4)); + int val_pk = sqlite3_column_int(vm, 5); + if(val_pk == 1) + val_type.append(QString(" PRIMARY KEY")); - sqlb::FieldPtr f(new sqlb::Field(val1, val2)); + sqlb::FieldPtr f(new sqlb::Field(val_name, val_type, val_nn, val_default)); (*it).addField(f); } }