Skip to content

Commit e125e3c

Browse files
committed
Handle nested records.
1 parent 3261a7b commit e125e3c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

graphql.sql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,18 @@ BEGIN
305305
IF sub.body IS NOT NULL THEN -- TODO: Nested JSON lookups
306306
RAISE EXCEPTION 'Nested JSON lookup is as yet unimplemented';
307307
END IF;
308+
lookups := lookups || format('->%L', sub.selector);
308309
WHEN regtype('hstore') THEN
309310
IF sub.body IS NOT NULL THEN
310311
RAISE EXCEPTION 'No fields below this level (column % is hstore)',
311312
tab, col;
312313
END IF;
314+
lookups := lookups || format('->%L', sub.selector);
313315
ELSE
314-
RAISE EXCEPTION 'Unhandled nested type %s for %s.%s', typ, tab, col;
316+
--- Treat it as a field lookup in a nested record (this could also end up
317+
--- being a function call, by the way).
318+
lookups := lookups || format('.%I', sub.selector);
315319
END CASE;
316-
lookups := lookups || format('->%L', sub.selector);
317320
labels := labels || format('%I', sub.selector);
318321
END LOOP;
319322
q := format(E'SELECT to_json(_) AS %I\n'

0 commit comments

Comments
 (0)