You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Embed JSON-aliased VARCHAR columns as nested JSON (#38) (#39)
DuckDB's JSON type is a logical-type alias over VARCHAR; the dispatch in QueryResult::convertVectorEntryToJson switched on the physical type id and routed JSON cells to the VARCHAR handler, so API consumers got an escaped string and had to JSON.parse a second time.
Inspect the logical-type alias before dispatching. When it equals the literal "JSON" that DuckDB sets on LogicalType::JSON(), route to a new convertVectorJsonToJson helper that parses with crow::json::load and embeds the result via wvalue(const rvalue&). Nested objects and arrays now travel through the response unchanged. Malformed JSON degrades to the raw string rather than nulling the row.
Also destroy the logical type on every exit path of convertVectorEntryToJson; the dead destroy below the switch was unreachable, leaking one logical-type allocation per emitted cell.
Tests added TDD-style (red → green):
- unit: nested object, JSON array, NULL JSON, plain-VARCHAR regression guard.
- integration: GET /json-demo/ returns the exact "Expected" shape from the issue.
Closes#38
0 commit comments