0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd::db: Move set() for json::tuple; check for undefined.

This commit is contained in:
Jason Volk 2017-09-16 09:39:39 -07:00
parent 65802d3e47
commit c58836ed56
2 changed files with 6 additions and 17 deletions

View file

@ -203,7 +203,12 @@ const
{
if(stale)
{
set(v, row);
for(const auto &cell : row)
if(cell.valid() && cell.key() == idx->first)
json::set(v, cell.col(), cell.val());
else
json::set(v, cell.col(), string_view{});
stale = false;
}

View file

@ -25,9 +25,7 @@
namespace ircd::db
{
template<class... T> json::tuple<T...> &set(json::tuple<T...> &, const row &r);
template<class tuple> tuple make_tuple(const row &r);
template<class it> void set_index(it begin, it end, const string_view &index);
template<class... T> void write(database &, const string_view &index, const json::tuple<T...> &, const sopts & = {});
}
@ -68,17 +66,3 @@ ircd::db::make_tuple(const row &row)
set(ret, row);
return ret;
}
template<class... T>
ircd::json::tuple<T...> &
ircd::db::set(json::tuple<T...> &tuple,
const row &row)
{
for(const auto &cell : row)
if(cell.valid())
json::set(tuple, cell.col(), cell.val());
else
json::set(tuple, cell.col(), string_view{});
return tuple;
}