From ac5bdf4c01e015f17c078353fe6aa0406fd6bcce Mon Sep 17 00:00:00 2001 From: Mateusz Grzywacz Date: Thu, 16 Jul 2020 00:32:34 +0200 Subject: [PATCH] [feature] move ContactsAddressTableRow to Record --- module-db/Interface/ContactRecord.cpp | 11 +++++++---- module-db/Tables/ContactsAddressTable.hpp | 9 ++++----- module-db/tests/ContactsAddressTable_tests.cpp | 2 +- module-db/tests/ContactsTable_tests.cpp | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/module-db/Interface/ContactRecord.cpp b/module-db/Interface/ContactRecord.cpp index 0744d5a83..6174bd2b3 100644 --- a/module-db/Interface/ContactRecord.cpp +++ b/module-db/Interface/ContactRecord.cpp @@ -66,8 +66,8 @@ bool ContactRecordInterface::Add(const ContactRecord &rec) auto contactRingID = contactDB->getLastInsertRowId(); - ret = contactDB->address.add( - ContactsAddressTableRow{.contactID = contactID, .address = rec.address, .note = rec.note, .mail = rec.mail}); + ret = contactDB->address.add(ContactsAddressTableRow{ + {.ID = DB_ID_NONE}, .contactID = contactID, .address = rec.address, .note = rec.note, .mail = rec.mail}); if (!ret) { return ret; @@ -223,8 +223,11 @@ bool ContactRecordInterface::Update(const ContactRecord &rec) if (!ret) return ret; - ret = contactDB->address.update(ContactsAddressTableRow{ - .ID = contact.addressID, .contactID = contact.ID, .address = rec.address, .note = rec.note, .mail = rec.mail}); + ret = contactDB->address.update(ContactsAddressTableRow{{.ID = contact.addressID}, + .contactID = contact.ID, + .address = rec.address, + .note = rec.note, + .mail = rec.mail}); if (!ret) return ret; diff --git a/module-db/Tables/ContactsAddressTable.hpp b/module-db/Tables/ContactsAddressTable.hpp index f4d96a440..41195cb45 100644 --- a/module-db/Tables/ContactsAddressTable.hpp +++ b/module-db/Tables/ContactsAddressTable.hpp @@ -4,13 +4,12 @@ #include "Record.hpp" #include "utf8/UTF8.hpp" -struct ContactsAddressTableRow +struct ContactsAddressTableRow : public Record { - uint32_t ID = DB_ID_NONE; uint32_t contactID = DB_ID_NONE; - UTF8 address = ""; - UTF8 note = ""; - UTF8 mail = ""; + UTF8 address; + UTF8 note; + UTF8 mail; }; enum class ContactAddressTableFields diff --git a/module-db/tests/ContactsAddressTable_tests.cpp b/module-db/tests/ContactsAddressTable_tests.cpp index 3e2bbbc93..ff35b4f4a 100644 --- a/module-db/tests/ContactsAddressTable_tests.cpp +++ b/module-db/tests/ContactsAddressTable_tests.cpp @@ -12,7 +12,7 @@ TEST_CASE("Contacts address Table tests") ContactsDB contactsdb; REQUIRE(contactsdb.isInitialized()); - ContactsAddressTableRow testRow1 = {.ID = 0, + ContactsAddressTableRow testRow1 = {{.ID = DB_ID_NONE}, .contactID = 0, .address = "6 Czeczota St.\n02600 Warsaw", .note = "Test note", diff --git a/module-db/tests/ContactsTable_tests.cpp b/module-db/tests/ContactsTable_tests.cpp index 2564eb5cb..5335cea90 100644 --- a/module-db/tests/ContactsTable_tests.cpp +++ b/module-db/tests/ContactsTable_tests.cpp @@ -14,7 +14,7 @@ TEST_CASE("Contacts Table tests") ContactsDB contactsdb; REQUIRE(contactsdb.isInitialized()); - ContactsTableRow testRow1 = {.ID = 0, + ContactsTableRow testRow1 = {{.ID = DB_ID_NONE}, .nameID = 0, .numbersID = "0 1 2 3 4", .ringID = 0,