-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes to avoid crash with duplicate ids when adding userpoints or log…
…book entries. albar965/littlenavmap#985
- Loading branch information
Showing
3 changed files
with
23 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/***************************************************************************** | ||
* Copyright 2015-2020 Alexander Barthel [email protected] | ||
* Copyright 2015-2023 Alexander Barthel [email protected] | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -34,17 +34,15 @@ QVariant SqlRecord::value(int i) const | |
{ | ||
QVariant retval = sqlRecord.value(i); | ||
if(!retval.isValid()) | ||
throw SqlException("SqlRecord::value(): Value index " + QString::number( | ||
i) + " does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::value(): Value index " + QString::number(i) + " does not exist in query \"" + queryString + "\""); | ||
return retval; | ||
} | ||
|
||
QVariant SqlRecord::value(const QString& name) const | ||
{ | ||
QVariant retval = sqlRecord.value(name); | ||
if(!retval.isValid()) | ||
throw SqlException("SqlRecord::value(): Value name \"" + | ||
name + "\" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::value(): Value name \"" + name + "\" does not exist in query \"" + queryString + "\""); | ||
return retval; | ||
|
||
} | ||
|
@@ -67,71 +65,63 @@ QDateTime SqlRecord::valueDateTime(const QString& name, const QDateTime& default | |
bool SqlRecord::isNull(int i) const | ||
{ | ||
if(sqlRecord.fieldName(i).isEmpty()) | ||
throw SqlException("SqlRecord::isNull(): Field index " + QString::number(i) + | ||
" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::isNull(): Field index " + QString::number(i) + " does not exist in query \"" + queryString + "\""); | ||
|
||
return sqlRecord.isNull(i); | ||
} | ||
|
||
bool SqlRecord::isNull(const QString& name) const | ||
{ | ||
if(sqlRecord.indexOf(name) == -1) | ||
throw SqlException("SqlRecord::indexOf(): Field name \"" + | ||
name + "\" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::indexOf(): Field name \"" + name + "\" does not exist in query \"" + queryString + "\""); | ||
return sqlRecord.isNull(name); | ||
} | ||
|
||
int SqlRecord::indexOf(const QString& name) const | ||
{ | ||
int retval = sqlRecord.indexOf(name); | ||
if(retval == -1) | ||
throw SqlException("SqlRecord::indexOf(): Field name \"" + | ||
name + "\" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::indexOf(): Field name \"" + name + "\" does not exist in query \"" + queryString + "\""); | ||
return retval; | ||
} | ||
|
||
QString SqlRecord::fieldName(int i) const | ||
{ | ||
QString retval = sqlRecord.fieldName(i); | ||
if(retval.isEmpty()) | ||
throw SqlException("SqlRecord::fieldName(): Field index " + QString::number(i) + | ||
" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::fieldName(): Field index " + QString::number(i) + " does not exist in query \"" + queryString + "\""); | ||
return retval; | ||
} | ||
|
||
QVariant::Type SqlRecord::fieldType(int i) const | ||
{ | ||
QSqlField retval = sqlRecord.field(i); | ||
if(sqlRecord.fieldName(i).isEmpty()) | ||
throw SqlException("SqlRecord::fieldType(): Field index " + QString::number(i) + | ||
" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::fieldType(): Field index " + QString::number(i) + " does not exist in query \"" + queryString + "\""); | ||
return retval.type(); | ||
} | ||
|
||
QVariant::Type SqlRecord::fieldType(const QString& name) const | ||
{ | ||
QSqlField retval = sqlRecord.field(name); | ||
if(!contains(name)) | ||
throw SqlException("SqlRecord::fieldType(): Field name \"" + | ||
name + "\" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::fieldType(): Field name \"" + name + "\" does not exist in query \"" + queryString + "\""); | ||
|
||
return retval.type(); | ||
} | ||
|
||
bool SqlRecord::isGenerated(int i) const | ||
{ | ||
if(sqlRecord.fieldName(i).isEmpty()) | ||
throw SqlException("SqlRecord::isGenerated(): Field index " + QString::number(i) + | ||
" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::isGenerated(): Field index " + QString::number(i) + " does not exist in query \"" + queryString + "\""); | ||
|
||
return sqlRecord.isGenerated(i); | ||
} | ||
|
||
bool SqlRecord::isGenerated(const QString& name) const | ||
{ | ||
if(!contains(name)) | ||
throw SqlException("SqlRecord::isGenerated(): Field name \"" + | ||
name + "\" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::isGenerated(): Field name \"" + name + "\" does not exist in query \"" + queryString + "\""); | ||
return sqlRecord.isGenerated(name); | ||
} | ||
|
||
|
@@ -243,32 +233,28 @@ QVariantList SqlRecord::values() const | |
void SqlRecord::setValue(int i, const QVariant& val) | ||
{ | ||
if(sqlRecord.fieldName(i).isEmpty()) | ||
throw SqlException("SqlRecord::setValue(): Field index " + QString::number(i) + | ||
" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::setValue(): Field index " + QString::number(i) + " does not exist in query \"" + queryString + "\""); | ||
sqlRecord.setValue(i, val); | ||
} | ||
|
||
void SqlRecord::setValue(const QString& name, const QVariant& val) | ||
{ | ||
if(sqlRecord.indexOf(name) == -1) | ||
throw SqlException("SqlRecord::setValue(): Field name \"" + | ||
name + "\" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::setValue(): Field name \"" + name + "\" does not exist in query \"" + queryString + "\""); | ||
sqlRecord.setValue(name, val); | ||
} | ||
|
||
void SqlRecord::setNull(int i) | ||
{ | ||
if(sqlRecord.fieldName(i).isEmpty()) | ||
throw SqlException("SqlRecord::setNull(): Field index " + QString::number(i) + | ||
" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::setNull(): Field index " + QString::number(i) + " does not exist in query \"" + queryString + "\""); | ||
sqlRecord.setNull(i); | ||
} | ||
|
||
void SqlRecord::setNull(const QString& name) | ||
{ | ||
if(sqlRecord.indexOf(name) == -1) | ||
throw SqlException("SqlRecord::setNull(): Field name \"" + | ||
name + "\" does not exist in query \"" + queryString + "\""); | ||
throw SqlException("SqlRecord::setNull(): Field name \"" + name + "\" does not exist in query \"" + queryString + "\""); | ||
sqlRecord.setNull(name); | ||
} | ||
|
||
|