0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 08:42:34 +01:00

ircd:Ⓜ️:dbs: Add branch to canonize content for select column types.

This commit is contained in:
Jason Volk 2020-11-29 15:27:41 -08:00
parent 9ea6fe65c3
commit d4cab12056

View file

@ -944,6 +944,20 @@ ircd::m::dbs::_index_event_cols(db::txn &txn,
if(value_required(opts.op) && !defined(json::value(val))) if(value_required(opts.op) && !defined(json::value(val)))
return; return;
// If an already-strung json::object is carried by the event we
// re-stringify it into a temporary buffer. This is the common case
// because the original source might be crap JSON w/ spaces etc.
constexpr bool canonizable
{
std::is_same<decltype(val), json::object>() ||
std::is_same<decltype(val), json::array>() ||
std::is_same<decltype(val), json::string>()
};
if constexpr(canonizable)
if(opts.op == db::op::SET && !opts.json_source)
val = json::stringify(mutable_buffer{event::buf[0]}, val);
db::txn::append db::txn::append
{ {
txn, column, db::column::delta txn, column, db::column::delta