Commit 1f8f7652 authored by Ronan's avatar Ronan

fix(MainDb): add a compatible trigger char message participant deleter with mysql

parent f2a25777
......@@ -42,7 +42,7 @@ namespace Statements {
// TODO: Improve, check backends.
constexpr AbstractStatement (const Statement &a, const Statement &b) : mSql{ a.sql, b.sql } {}
const char *getSql (Backend backend) const {
const char *get (Backend backend) const {
return backend == Backend::Mysql && mSql[1] ? mSql[1] : mSql[0];
}
......@@ -85,7 +85,7 @@ namespace Statements {
// Select statements.
// ---------------------------------------------------------------------------
constexpr const char *select[SelectCount] = {
constexpr AbstractStatement select[SelectCount] = {
[SelectSipAddressId] = R"(
SELECT id
FROM sip_address
......@@ -126,7 +126,7 @@ namespace Statements {
// Select statements.
// ---------------------------------------------------------------------------
constexpr const char *insert[InsertCount] = {
constexpr AbstractStatement insert[InsertCount] = {
[InsertOneToOneChatRoom] = R"(
INSERT INTO one_to_one_chat_room (
chat_room_id, participant_a_sip_address_id, participant_b_sip_address_id
......@@ -139,18 +139,15 @@ namespace Statements {
// ---------------------------------------------------------------------------
const char *get (Create createStmt, AbstractDb::Backend backend) {
(void)backend;
return createStmt >= Create::CreateCount ? nullptr : create[createStmt].getSql(backend);
return createStmt >= Create::CreateCount ? nullptr : create[createStmt].get(backend);
}
const char *get (Select selectStmt, AbstractDb::Backend backend) {
(void)backend;
return selectStmt >= Select::SelectCount ? nullptr : select[selectStmt];
return selectStmt >= Select::SelectCount ? nullptr : select[selectStmt].get(backend);
}
const char *get (Insert insertStmt, AbstractDb::Backend backend) {
(void)backend;
return insertStmt >= Insert::InsertCount ? nullptr : insert[insertStmt];
return insertStmt >= Insert::InsertCount ? nullptr : insert[insertStmt].get(backend);
}
}
......
......@@ -1697,7 +1697,9 @@ void MainDb::init () {
if (getBackend() == Backend::Mysql)
*session <<
"CREATE TRIGGER IF NOT EXISTS chat_message_participant_deleter"
"DROP TRIGGER IF EXISTS chat_message_participant_deleter";
*session <<
"CREATE TRIGGER chat_message_participant_deleter"
" AFTER UPDATE ON conference_chat_message_event FOR EACH ROW"
" BEGIN"
" IF NEW.state = " + Utils::toString(int(ChatMessage::State::Displayed)) + " THEN"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment