SqlQuery: add BindDoubleOrNullValue() method
To facilitate serializing of the two DB fields added by the previous change.
This commit is contained in:
committed by
Jonas Kvinge
parent
0a4888f861
commit
73c56f038e
@@ -72,6 +72,12 @@ void SqlQuery::BindFloatValue(const QString &placeholder, const float value) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SqlQuery::BindDoubleOrNullValue(const QString &placeholder, const std::optional<double> value) {
|
||||||
|
|
||||||
|
BindValue(placeholder, value.has_value() ? *value : QVariant());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void SqlQuery::BindBoolValue(const QString &placeholder, const bool value) {
|
void SqlQuery::BindBoolValue(const QString &placeholder, const bool value) {
|
||||||
|
|
||||||
BindValue(placeholder, value ? 1 : 0);
|
BindValue(placeholder, value ? 1 : 0);
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@@ -40,6 +42,7 @@ class SqlQuery : public QSqlQuery {
|
|||||||
void BindLongLongValue(const QString &placeholder, const qint64 value);
|
void BindLongLongValue(const QString &placeholder, const qint64 value);
|
||||||
void BindLongLongValueOrZero(const QString &placeholder, const qint64 value);
|
void BindLongLongValueOrZero(const QString &placeholder, const qint64 value);
|
||||||
void BindFloatValue(const QString &placeholder, const float value);
|
void BindFloatValue(const QString &placeholder, const float value);
|
||||||
|
void BindDoubleOrNullValue(const QString &placeholder, const std::optional<double> value);
|
||||||
void BindBoolValue(const QString &placeholder, const bool value);
|
void BindBoolValue(const QString &placeholder, const bool value);
|
||||||
void BindNotNullIntValue(const QString &placeholder, const int value);
|
void BindNotNullIntValue(const QString &placeholder, const int value);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user