Fixed original sql string not being passed to error callback
This commit is contained in:
parent
b1d29b5a4f
commit
17483ee199
@ -77,7 +77,7 @@ void LuaIQuery::runAbortedCallback(ILuaBase *LUA, const std::shared_ptr<IQueryDa
|
||||
LuaObject::pcallWithErrorReporter(LUA, 1);
|
||||
}
|
||||
|
||||
void LuaIQuery::runErrorCallback(ILuaBase *LUA, const std::shared_ptr<IQueryData> &data) {
|
||||
void LuaIQuery::runErrorCallback(ILuaBase *LUA, const std::shared_ptr<IQuery> &iQuery, const std::shared_ptr<IQueryData> &data) {
|
||||
if (data->m_tableReference == 0) return;
|
||||
|
||||
if (!LuaIQuery::pushCallbackReference(LUA, data->m_errorReference, data->m_tableReference,
|
||||
@ -87,7 +87,8 @@ void LuaIQuery::runErrorCallback(ILuaBase *LUA, const std::shared_ptr<IQueryData
|
||||
LUA->ReferencePush(data->m_tableReference);
|
||||
auto error = data->getError();
|
||||
LUA->PushString(error.c_str());
|
||||
LuaObject::pcallWithErrorReporter(LUA, 2);
|
||||
LUA->PushString(iQuery->getSQLString().c_str());
|
||||
LuaObject::pcallWithErrorReporter(LUA, 3);
|
||||
}
|
||||
|
||||
void LuaIQuery::addMetaTableFunctions(ILuaBase *LUA) {
|
||||
@ -160,7 +161,7 @@ void LuaIQuery::runCallback(ILuaBase *LUA, const std::shared_ptr<IQuery> &iQuery
|
||||
case QUERY_NONE:
|
||||
break; //Should not happen
|
||||
case QUERY_ERROR:
|
||||
runErrorCallback(LUA, data);
|
||||
runErrorCallback(LUA, iQuery, data);
|
||||
break;
|
||||
case QUERY_SUCCESS:
|
||||
if (auto query = std::dynamic_pointer_cast<Query>(iQuery)) {
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
|
||||
static void runAbortedCallback(ILuaBase *LUA, const std::shared_ptr<IQueryData> &data);
|
||||
|
||||
static void runErrorCallback(ILuaBase *LUA, const std::shared_ptr<IQueryData> &data);
|
||||
static void runErrorCallback(ILuaBase *LUA, const std::shared_ptr<IQuery> &iQuery, const std::shared_ptr<IQueryData> &data);
|
||||
|
||||
static void runCallback(ILuaBase *LUA, const std::shared_ptr<IQuery> &query, const std::shared_ptr<IQueryData> &data);
|
||||
|
||||
|
@ -75,6 +75,8 @@ public:
|
||||
|
||||
std::vector<std::shared_ptr<IQueryData>> abort();
|
||||
|
||||
virtual std::string getSQLString() = 0;
|
||||
|
||||
void wait(bool shouldSwap);
|
||||
|
||||
bool hasCallbackData() const {
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#ifndef PINGQUERY_
|
||||
#define PINGQUERY_
|
||||
|
||||
#include <unordered_map>
|
||||
#include "Query.h"
|
||||
#include "MySQLHeader.h"
|
||||
@ -9,12 +10,19 @@
|
||||
|
||||
|
||||
class PingQuery : public Query {
|
||||
friend class Database;
|
||||
friend class Database;
|
||||
|
||||
public:
|
||||
~PingQuery() override;
|
||||
~PingQuery() override;
|
||||
|
||||
protected:
|
||||
explicit PingQuery(const std::shared_ptr<Database>& dbase);
|
||||
void executeStatement(Database &database, MYSQL* m_sql, const std::shared_ptr<IQueryData> &data) override;
|
||||
bool pingSuccess = false;
|
||||
explicit PingQuery(const std::shared_ptr<Database> &dbase);
|
||||
|
||||
std::string getSQLString() override { return ""; };
|
||||
|
||||
void executeStatement(Database &database, MYSQL *m_sql, const std::shared_ptr<IQueryData> &data) override;
|
||||
|
||||
bool pingSuccess = false;
|
||||
};
|
||||
|
||||
#endif
|
@ -18,7 +18,7 @@ class Query : public IQuery {
|
||||
public:
|
||||
~Query() override;
|
||||
|
||||
void executeStatement(Database &database, MYSQL *m_sql, const std::shared_ptr<IQueryData>& data) override;
|
||||
void executeStatement(Database &database, MYSQL *m_sql, const std::shared_ptr<IQueryData> &data) override;
|
||||
|
||||
my_ulonglong lastInsert();
|
||||
|
||||
@ -32,7 +32,10 @@ public:
|
||||
|
||||
int m_dataReference = 0;
|
||||
|
||||
static std::shared_ptr<Query> create(const std::shared_ptr<Database> &dbase, const std::string& query);
|
||||
std::string getSQLString() override { return m_query; };
|
||||
|
||||
static std::shared_ptr<Query> create(const std::shared_ptr<Database> &dbase, const std::string &query);
|
||||
|
||||
protected:
|
||||
Query(const std::shared_ptr<Database> &dbase, std::string query);
|
||||
|
||||
@ -75,6 +78,7 @@ protected:
|
||||
std::deque<my_ulonglong> m_affectedRows;
|
||||
std::deque<my_ulonglong> m_insertIds;
|
||||
std::deque<ResultData> m_results;
|
||||
|
||||
QueryData() = default;
|
||||
};
|
||||
|
||||
|
@ -30,14 +30,17 @@ public:
|
||||
|
||||
static std::shared_ptr<Transaction> create(const std::shared_ptr<Database> &database);
|
||||
|
||||
std::string getSQLString() override { return ""; };
|
||||
|
||||
protected:
|
||||
void executeStatement(Database &database, MYSQL *connection, const std::shared_ptr<IQueryData>& data) override;
|
||||
void executeStatement(Database &database, MYSQL *connection, const std::shared_ptr<IQueryData> &data) override;
|
||||
|
||||
explicit Transaction(const std::shared_ptr<Database> &database) : IQuery(database) {
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
static void applyChildResultStatus(const std::shared_ptr<TransactionData>& data);
|
||||
static void applyChildResultStatus(const std::shared_ptr<TransactionData> &data);
|
||||
|
||||
static void mysqlAutocommit(MYSQL *sql, bool auto_mode);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user