Browse Source

added member variable that holds error information

fiffty-50 4 years ago
parent
commit
e44c326b79
5 changed files with 8 additions and 7 deletions
  1. 1 1
      src/classes/aircraft.cpp
  2. 1 1
      src/classes/flight.cpp
  3. 1 1
      src/classes/pilot.cpp
  4. 4 4
      src/database/entry.cpp
  5. 1 0
      src/database/entry.h

+ 1 - 1
src/classes/aircraft.cpp

@@ -54,7 +54,7 @@ Aircraft::Aircraft(int tail_id)
             data.insert(dbContent.format.value(table)[i], q.value(i).toString());
         }
 
-        QString error = q.lastError().text();
+        error = q.lastError().text();
         if (error.length() > 2) {
             DEB("Error: " << q.lastError().text());
             position.second = 0;

+ 1 - 1
src/classes/flight.cpp

@@ -55,7 +55,7 @@ Flight::Flight(int flight_id)
             data.insert(dbContent.format.value(table)[i], q.value(i).toString());
         }
 
-        QString error = q.lastError().text();
+        error = q.lastError().text();
         if (error.length() > 2) {
             DEB("Error: " << q.lastError().text());
             position.second = 0;

+ 1 - 1
src/classes/pilot.cpp

@@ -55,7 +55,7 @@ Pilot::Pilot(int pilot_id)
             data.insert(dbContent.format.value(table)[i], q.value(i).toString());
         }
 
-        QString error = q.lastError().text();
+        error = q.lastError().text();
         if (error.length() > 2) {
             DEB("Error: " << q.lastError().text());
             position.second = 0;

+ 4 - 4
src/database/entry.cpp

@@ -59,7 +59,7 @@ Entry::Entry(QString table, int row)
             data.insert(dbContent.format.value(table)[i], q.value(i).toString());
         }
 
-        QString error = q.lastError().text();
+        error = q.lastError().text();
         if (error.length() > 2) {
             DEB("Error: " << q.lastError().text());
             position.second = 0;
@@ -117,7 +117,7 @@ bool Entry::remove()
         QString statement = "DELETE FROM " + position.first +
                             " WHERE _rowid_=" + QString::number(position.second);
         QSqlQuery q(statement);
-        QString error = q.lastError().text();
+        error = q.lastError().text();
 
         if (error.length() > 1) {
             DEB("Errors have occured: " << error);
@@ -171,7 +171,7 @@ bool Entry::insert()
     statement += QLatin1String(")");
 
     QSqlQuery q(statement);
-    QString error = q.lastError().text();
+    error = q.lastError().text();
     if (error.length() < 2) {
         DEB("Entry successfully committed.");
         return true;
@@ -200,7 +200,7 @@ bool Entry::update()
     //execute query
     QSqlQuery q(statement);
     //check result. Upon success, error should be " "
-    QString error = q.lastError().text();
+    error = q.lastError().text();
     if (error.length() < 2) {
         DEB("Object successfully updated.");
         return true;

+ 1 - 0
src/database/entry.h

@@ -36,6 +36,7 @@ public:
     QPair   <QString, int>       position = QPair<QString, int>();    // Position within the database, i.e. <table,row>
     QVector <QString>            columns  = QVector<QString>();       // The columns within the table
     QMap    <QString, QString>   data     = QMap<QString, QString>(); // Tha data to fill that table, <column,value>
+    QString                      error    = QString();                // holds sql errors (if they ocurred)
 
     void setData(const QMap<QString, QString> &value);