Build nested JSON from path: ["a", "b", "c"] with value "v" -> {"a": {"b": {"c": "v"}}}
| 323 | |
| 324 | // Build nested JSON from path: ["a", "b", "c"] with value "v" -> {"a": {"b": {"c": "v"}}} |
| 325 | std::string build_nested_json(const std::vector<std::string>& path, const std::string& value) |
| 326 | { |
| 327 | if (path.empty()) |
| 328 | return ""; |
| 329 | |
| 330 | StringInfoData json; |
| 331 | initStringInfo(&json); |
| 332 | |
| 333 | // Open braces for each level |
| 334 | for (size_t i = 0; i < path.size(); i++) { |
| 335 | appendStringInfo(&json, "{\"%s\":", path[i].c_str()); |
| 336 | } |
| 337 | |
| 338 | // Add value |
| 339 | appendStringInfo(&json, "\"%s\"", value.c_str()); |
| 340 | |
| 341 | // Close braces |
| 342 | for (size_t i = 0; i < path.size(); i++) { |
| 343 | appendStringInfoChar(&json, '}'); |
| 344 | } |
| 345 | |
| 346 | std::string result(json.data); |
| 347 | pfree(json.data); |
| 348 | return result; |
| 349 | } |
| 350 | |
| 351 | // Transform ->> expressions into @> containment for JSONB index usage |
| 352 | void transform_jsonb_arrow_quals(Node** nodeptr) |
no test coverage detected