diff --git a/plugins/sql.c b/plugins/sql.c index f066ab9893c8..9493696a343a 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 = "";