From 9a6325c4f30e40141d783113f5cd8cb29c03f731 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 15 Aug 2024 16:35:32 +0930 Subject: [PATCH] doc: properly document sub-subobject fields. Inside listpeerchannels, there's an object called `updates`, and inside that objects `local` and `remote`. We flatten this, but the documentation doesn't mention the `updates` field at all. Ideally we would rename these fields to include `updates_` but that would be a breaking change. Signed-off-by: Rusty Russell ``` - `row` (reference to `peerchannels_channel_type.rowid`, sqltype `INTEGER`) - `arrindex` (index within array, sqltype `INTEGER`) - `names` (type `string`, sqltype `TEXT`) - - `local_htlc_minimum_msat` (type `msat`, sqltype `INTEGER`, from JSON object `local`) - - `local_htlc_maximum_msat` (type `msat`, sqltype `INTEGER`, from JSON object `local`) - - `local_cltv_expiry_delta` (type `u32`, sqltype `INTEGER`, from JSON object `local`) - - `local_fee_base_msat` (type `msat`, sqltype `INTEGER`, from JSON object `local`) - - `local_fee_proportional_millionths` (type `u32`, sqltype `INTEGER`, from JSON object `local`) - - `remote_htlc_minimum_msat` (type `msat`, sqltype `INTEGER`, from JSON object `remote`) - - `remote_htlc_maximum_msat` (type `msat`, sqltype `INTEGER`, from JSON object `remote`) - - `remote_cltv_expiry_delta` (type `u32`, sqltype `INTEGER`, from JSON object `remote`) - - `remote_fee_base_msat` (type `msat`, sqltype `INTEGER`, from JSON object `remote`) - - `remote_fee_proportional_millionths` (type `u32`, sqltype `INTEGER`, from JSON object `remote`) + - `local_htlc_minimum_msat` (type `msat`, sqltype `INTEGER`, from JSON object `updates.local`) + - `local_htlc_maximum_msat` (type `msat`, sqltype `INTEGER`, from JSON object `updates.local`) + - `local_cltv_expiry_delta` (type `u32`, sqltype `INTEGER`, from JSON object `updates.local`) + - `local_fee_base_msat` (type `msat`, sqltype `INTEGER`, from JSON object `updates.local`) + - `local_fee_proportional_millionths` (type `u32`, sqltype `INTEGER`, from JSON object `updates.local`) + - `remote_htlc_minimum_msat` (type `msat`, sqltype `INTEGER`, from JSON object `updates.remote`) + - `remote_htlc_maximum_msat` (type `msat`, sqltype `INTEGER`, from JSON object `updates.remote`) + - `remote_cltv_expiry_delta` (type `u32`, sqltype `INTEGER`, from JSON object `updates.remote`) + - `remote_fee_base_msat` (type `msat`, sqltype `INTEGER`, from JSON object `updates.remote`) + - `remote_fee_proportional_millionths` (type `u32`, sqltype `INTEGER`, from JSON object `updates.remote`) - `ignore_fee_limits` (type `boolean`, sqltype `INTEGER`) - `lost_state` (type `boolean`, sqltype `INTEGER`) - `feerate_perkw` (type `u32`, sqltype `INTEGER`, from JSON object `feerate`) ``` --- plugins/sql.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/sql.c b/plugins/sql.c index f066ab989..9493696a3 100644 --- a/plugins/sql.c +++ b/plugins/sql.c @@ -1581,6 +1581,14 @@ static const char *fmt_indexes(const tal_t *ctx, const char *table) return tal_fmt(ctx, " indexed by `%s`", ret); } +static const char *json_prefix(const tal_t *ctx, + const struct table_desc *td) +{ + if (td->is_subobject) + return tal_fmt(ctx, "%s%s.", json_prefix(tmpctx, td->parent), td->cmdname); + return ""; +} + static void print_columns(const struct table_desc *td, const char *indent, const char *objsrc) { @@ -1603,7 +1611,8 @@ static void print_columns(const struct table_desc *td, const char *indent, const char *subobjsrc; subobjsrc = tal_fmt(tmpctx, - ", from JSON object `%s`", + ", from JSON object `%s%s`", + json_prefix(tmpctx, td), td->columns[i]->jsonname); print_columns(subtd, indent, subobjsrc); } @@ -1613,7 +1622,8 @@ static void print_columns(const struct table_desc *td, const char *indent, if (streq(objsrc, "") && td->columns[i]->jsonname && !streq(td->columns[i]->dbname, td->columns[i]->jsonname)) { - origin = tal_fmt(tmpctx, ", from JSON field `%s`", + origin = tal_fmt(tmpctx, ", from JSON field `%s%s`", + json_prefix(tmpctx, td), td->columns[i]->jsonname); } else origin = "";