From 528b5938ec71abed396248cf5e00f346e685aaea Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 14 Aug 2024 02:40:48 +0100 Subject: Automatically determine SQL column type from the field. Also add more column types to ensure we are storing data in the best format in the database. --- modules/chanserv/cs_entrymsg.cpp | 8 ++++---- modules/chanserv/cs_log.cpp | 16 ++++++++-------- modules/chanserv/cs_mode.cpp | 12 ++++++------ modules/chanserv/cs_seen.cpp | 14 +++++++------- modules/chanserv/cs_set.cpp | 2 +- modules/chanserv/cs_set_misc.cpp | 6 +++--- modules/chanserv/cs_suspend.cpp | 10 +++++----- 7 files changed, 34 insertions(+), 34 deletions(-) (limited to 'modules/chanserv') diff --git a/modules/chanserv/cs_entrymsg.cpp b/modules/chanserv/cs_entrymsg.cpp index efe13d1aa..808582bdc 100644 --- a/modules/chanserv/cs_entrymsg.cpp +++ b/modules/chanserv/cs_entrymsg.cpp @@ -32,10 +32,10 @@ struct EntryMsgImpl final void Serialize(Serialize::Data &data) const override { - data["ci"] << this->chan; - data["creator"] << this->creator; - data["message"] << this->message; - data.SetType("when", Serialize::Data::DT_INT); data["when"] << this->when; + data.Store("ci", this->chan); + data.Store("creator", this->creator); + data.Store("message", this->message); + data.Store("when", this->when); } static Serializable *Unserialize(Serializable *obj, Serialize::Data &data); diff --git a/modules/chanserv/cs_log.cpp b/modules/chanserv/cs_log.cpp index defd38287..e06d3d42b 100644 --- a/modules/chanserv/cs_log.cpp +++ b/modules/chanserv/cs_log.cpp @@ -37,14 +37,14 @@ struct LogSettingImpl final void Serialize(Serialize::Data &data) const override { - data["ci"] << chan; - data["service_name"] << service_name; - data["command_service"] << command_service; - data["command_name"] << command_name; - data["method"] << method; - data["extra"] << extra; - data["creator"] << creator; - data.SetType("created", Serialize::Data::DT_INT); data["created"] << created; + data.Store("ci", chan); + data.Store("service_name", service_name); + data.Store("command_service", command_service); + data.Store("command_name", command_name); + data.Store("method", method); + data.Store("extra", extra); + data.Store("creator", creator); + data.Store("created", created); } static Serializable *Unserialize(Serializable *obj, Serialize::Data &data) diff --git a/modules/chanserv/cs_mode.cpp b/modules/chanserv/cs_mode.cpp index 1ea0e9716..9962d1d2f 100644 --- a/modules/chanserv/cs_mode.cpp +++ b/modules/chanserv/cs_mode.cpp @@ -205,12 +205,12 @@ struct ModeLocksImpl final void ModeLockImpl::Serialize(Serialize::Data &data) const { - data["ci"] << this->ci; - data["set"] << this->set; - data["name"] << this->name; - data["param"] << this->param; - data["setter"] << this->setter; - data.SetType("created", Serialize::Data::DT_INT); data["created"] << this->created; + data.Store("ci", this->ci); + data.Store("set", this->set); + data.Store("name", this->name); + data.Store("param", this->param); + data.Store("setter", this->setter); + data.Store("created", this->created); } Serializable *ModeLockImpl::Unserialize(Serializable *obj, Serialize::Data &data) diff --git a/modules/chanserv/cs_seen.cpp b/modules/chanserv/cs_seen.cpp index 1603983f5..97d23ee70 100644 --- a/modules/chanserv/cs_seen.cpp +++ b/modules/chanserv/cs_seen.cpp @@ -46,13 +46,13 @@ struct SeenInfo final void Serialize(Serialize::Data &data) const override { - data["nick"] << nick; - data["vhost"] << vhost; - data["type"] << type; - data["nick2"] << nick2; - data["channel"] << channel; - data["message"] << message; - data.SetType("last", Serialize::Data::DT_INT); data["last"] << last; + data.Store("nick", nick); + data.Store("vhost", vhost); + data.Store("type", type); + data.Store("nick2", nick2); + data.Store("channel", channel); + data.Store("message", message); + data.Store("last", last); } static Serializable *Unserialize(Serializable *obj, Serialize::Data &data) diff --git a/modules/chanserv/cs_set.cpp b/modules/chanserv/cs_set.cpp index 932d1f43c..4f39574af 100644 --- a/modules/chanserv/cs_set.cpp +++ b/modules/chanserv/cs_set.cpp @@ -1068,7 +1068,7 @@ class CSSet final if (!last_value.empty()) modes += "," + last_value; } - data["last_modes"] << modes; + data.Store("last_modes", modes); } void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override diff --git a/modules/chanserv/cs_set_misc.cpp b/modules/chanserv/cs_set_misc.cpp index 685ab8022..4ad0ee7a1 100644 --- a/modules/chanserv/cs_set_misc.cpp +++ b/modules/chanserv/cs_set_misc.cpp @@ -46,9 +46,9 @@ struct CSMiscData final void Serialize(Serialize::Data &sdata) const override { - sdata["ci"] << this->object; - sdata["name"] << this->name; - sdata["data"] << this->data; + sdata.Store("ci", this->object); + sdata.Store("name", this->name); + sdata.Store("data", this->data); } static Serializable *Unserialize(Serializable *obj, Serialize::Data &data) diff --git a/modules/chanserv/cs_suspend.cpp b/modules/chanserv/cs_suspend.cpp index 03eb36c48..846f4fd59 100644 --- a/modules/chanserv/cs_suspend.cpp +++ b/modules/chanserv/cs_suspend.cpp @@ -20,11 +20,11 @@ struct CSSuspendInfo final void Serialize(Serialize::Data &data) const override { - data["chan"] << what; - data["by"] << by; - data["reason"] << reason; - data["time"] << when; - data["expires"] << expires; + data.Store("chan", what); + data.Store("by", by); + data.Store("reason", reason); + data.Store("time", when); + data.Store("expires", expires); } static Serializable *Unserialize(Serializable *obj, Serialize::Data &data) -- cgit