mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-26 22:35:55 +03:00
Logging: Print enum before cast in SqlQuer::bindValue
This commit is contained in:
parent
b9638bc778
commit
29c6f44124
3 changed files with 20 additions and 5 deletions
|
@ -361,10 +361,8 @@ auto SqlQuery::next() -> NextResult
|
|||
return result;
|
||||
}
|
||||
|
||||
void SqlQuery::bindValue(int pos, const QVariant &value)
|
||||
void SqlQuery::bindValueInternal(int pos, const QVariant &value)
|
||||
{
|
||||
qCDebug(lcSql) << "SQL bind" << pos << value;
|
||||
|
||||
int res = -1;
|
||||
if (!_stmt) {
|
||||
ASSERT(false);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#ifndef OWNSQL_H
|
||||
#define OWNSQL_H
|
||||
|
||||
#include <QLoggingCategory>
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
|
@ -28,6 +29,7 @@ struct sqlite3;
|
|||
struct sqlite3_stmt;
|
||||
|
||||
namespace OCC {
|
||||
OCSYNC_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcSql)
|
||||
|
||||
class SqlQuery;
|
||||
|
||||
|
@ -136,13 +138,28 @@ public:
|
|||
};
|
||||
NextResult next();
|
||||
|
||||
void bindValue(int pos, const QVariant &value);
|
||||
template<class T, typename std::enable_if<std::is_enum<T>::value, int>::type = 0>
|
||||
void bindValue(int pos, const T &value)
|
||||
{
|
||||
qCDebug(lcSql) << "SQL bind" << pos << value;
|
||||
bindValueInternal(pos, static_cast<int>(value));
|
||||
}
|
||||
|
||||
template<class T, typename std::enable_if<!std::is_enum<T>::value, int>::type = 0>
|
||||
void bindValue(int pos, const T &value)
|
||||
{
|
||||
qCDebug(lcSql) << "SQL bind" << pos << value;
|
||||
bindValueInternal(pos, value);
|
||||
}
|
||||
|
||||
QString lastQuery() const;
|
||||
int numRowsAffected();
|
||||
void reset_and_clear_bindings();
|
||||
void finish();
|
||||
|
||||
private:
|
||||
void bindValueInternal(int pos, const QVariant &value);
|
||||
|
||||
SqlDatabase *_sqldb = nullptr;
|
||||
sqlite3 *_db = nullptr;
|
||||
sqlite3_stmt *_stmt = nullptr;
|
||||
|
|
|
@ -2272,7 +2272,7 @@ void SyncJournalDb::PinStateInterface::setForPath(const QByteArray &path, PinSta
|
|||
"INSERT OR REPLACE INTO flags(path, pinState) VALUES(?1, ?2);"),
|
||||
_db->_db));
|
||||
query.bindValue(1, path);
|
||||
query.bindValue(2, static_cast<int>(state));
|
||||
query.bindValue(2, state);
|
||||
query.exec();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue