diff options
author | fiaxh <git@lightrise.org> | 2020-06-10 23:40:00 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2020-06-10 23:40:00 +0200 |
commit | 0beb592c5a6a2767e11a892bdb5ac9bcc5283c38 (patch) | |
tree | bea2894d322472292590ec126dc1b52543a10a7e /libdino | |
parent | 50c55c7f55aff6622d242bdcf2b58d5f7956f28e (diff) | |
download | dino-0beb592c5a6a2767e11a892bdb5ac9bcc5283c38.tar.gz dino-0beb592c5a6a2767e11a892bdb5ac9bcc5283c38.zip |
Use sqlite UPSERT
Diffstat (limited to 'libdino')
-rw-r--r-- | libdino/src/entity/message.vala | 4 | ||||
-rw-r--r-- | libdino/src/entity/settings.vala | 20 | ||||
-rw-r--r-- | libdino/src/service/roster_manager.vala | 6 |
3 files changed, 21 insertions, 9 deletions
diff --git a/libdino/src/entity/message.vala b/libdino/src/entity/message.vala index bce3bec4..89ad241a 100644 --- a/libdino/src/entity/message.vala +++ b/libdino/src/entity/message.vala @@ -196,8 +196,8 @@ public class Message : Object { update_builder.perform(); if (sp.get_name() == "real-jid") { - db.real_jid.insert().or("REPLACE") - .value(db.real_jid.message_id, id) + db.real_jid.upsert() + .value(db.real_jid.message_id, id, true) .value(db.real_jid.real_jid, real_jid.to_string()) .perform(); } diff --git a/libdino/src/entity/settings.vala b/libdino/src/entity/settings.vala index bf1ebed4..2aae6055 100644 --- a/libdino/src/entity/settings.vala +++ b/libdino/src/entity/settings.vala @@ -22,7 +22,10 @@ public class Settings : Object { public bool send_typing { get { return send_typing_; } set { - db.settings.insert().or("REPLACE").value(db.settings.key, "send_typing").value(db.settings.value, value.to_string()).perform(); + db.settings.upsert() + .value(db.settings.key, "send_typing", true) + .value(db.settings.value, value.to_string()) + .perform(); send_typing_ = value; } } @@ -31,7 +34,10 @@ public class Settings : Object { public bool send_marker { get { return send_marker_; } set { - db.settings.insert().or("REPLACE").value(db.settings.key, "send_marker").value(db.settings.value, value.to_string()).perform(); + db.settings.upsert() + .value(db.settings.key, "send_marker", true) + .value(db.settings.value, value.to_string()) + .perform(); send_marker_ = value; } } @@ -40,7 +46,10 @@ public class Settings : Object { public bool notifications { get { return notifications_; } set { - db.settings.insert().or("REPLACE").value(db.settings.key, "notifications").value(db.settings.value, value.to_string()).perform(); + db.settings.upsert() + .value(db.settings.key, "notifications", true) + .value(db.settings.value, value.to_string()) + .perform(); notifications_ = value; } } @@ -49,7 +58,10 @@ public class Settings : Object { public bool convert_utf8_smileys { get { return convert_utf8_smileys_; } set { - db.settings.insert().or("REPLACE").value(db.settings.key, "convert_utf8_smileys").value(db.settings.value, value.to_string()).perform(); + db.settings.upsert() + .value(db.settings.key, "convert_utf8_smileys", true) + .value(db.settings.value, value.to_string()) + .perform(); convert_utf8_smileys_ = value; } } diff --git a/libdino/src/service/roster_manager.vala b/libdino/src/service/roster_manager.vala index 62428882..8d9d91fb 100644 --- a/libdino/src/service/roster_manager.vala +++ b/libdino/src/service/roster_manager.vala @@ -128,9 +128,9 @@ public class RosterStoreImpl : Roster.Storage, Object { public void set_item(Roster.Item item) { items[item.jid] = item; - db.roster.insert().or("REPLACE") - .value(db.roster.account_id, account.id) - .value(db.roster.jid, item.jid.to_string()) + db.roster.upsert() + .value(db.roster.account_id, account.id, true) + .value(db.roster.jid, item.jid.to_string(), true) .value(db.roster.handle, item.name) .value(db.roster.subscription, item.subscription) .perform(); |