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 { ...@@ -42,7 +42,7 @@ namespace Statements {
// TODO: Improve, check backends. // TODO: Improve, check backends.
constexpr AbstractStatement (const Statement &a, const Statement &b) : mSql{ a.sql, b.sql } {} 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]; return backend == Backend::Mysql && mSql[1] ? mSql[1] : mSql[0];
} }
...@@ -85,7 +85,7 @@ namespace Statements { ...@@ -85,7 +85,7 @@ namespace Statements {
// Select statements. // Select statements.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
constexpr const char *select[SelectCount] = { constexpr AbstractStatement select[SelectCount] = {
[SelectSipAddressId] = R"( [SelectSipAddressId] = R"(
SELECT id SELECT id
FROM sip_address FROM sip_address
...@@ -126,7 +126,7 @@ namespace Statements { ...@@ -126,7 +126,7 @@ namespace Statements {
// Select statements. // Select statements.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
constexpr const char *insert[InsertCount] = { constexpr AbstractStatement insert[InsertCount] = {
[InsertOneToOneChatRoom] = R"( [InsertOneToOneChatRoom] = R"(
INSERT INTO one_to_one_chat_room ( INSERT INTO one_to_one_chat_room (
chat_room_id, participant_a_sip_address_id, participant_b_sip_address_id chat_room_id, participant_a_sip_address_id, participant_b_sip_address_id
...@@ -139,18 +139,15 @@ namespace Statements { ...@@ -139,18 +139,15 @@ namespace Statements {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
const char *get (Create createStmt, AbstractDb::Backend backend) { const char *get (Create createStmt, AbstractDb::Backend backend) {
(void)backend; return createStmt >= Create::CreateCount ? nullptr : create[createStmt].get(backend);
return createStmt >= Create::CreateCount ? nullptr : create[createStmt].getSql(backend);
} }
const char *get (Select selectStmt, AbstractDb::Backend backend) { const char *get (Select selectStmt, AbstractDb::Backend backend) {
(void)backend; return selectStmt >= Select::SelectCount ? nullptr : select[selectStmt].get(backend);
return selectStmt >= Select::SelectCount ? nullptr : select[selectStmt];
} }
const char *get (Insert insertStmt, AbstractDb::Backend backend) { const char *get (Insert insertStmt, AbstractDb::Backend backend) {
(void)backend; return insertStmt >= Insert::InsertCount ? nullptr : insert[insertStmt].get(backend);
return insertStmt >= Insert::InsertCount ? nullptr : insert[insertStmt];
} }
} }
......
...@@ -1697,7 +1697,9 @@ void MainDb::init () { ...@@ -1697,7 +1697,9 @@ void MainDb::init () {
if (getBackend() == Backend::Mysql) if (getBackend() == Backend::Mysql)
*session << *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" " AFTER UPDATE ON conference_chat_message_event FOR EACH ROW"
" BEGIN" " BEGIN"
" IF NEW.state = " + Utils::toString(int(ChatMessage::State::Displayed)) + " THEN" " 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