@@ -148,7 +148,7 @@ DECLARE
148
148
subselects text [] = ARRAY[]::text [];
149
149
predicates text [] = ARRAY[]::text [];
150
150
BEGIN
151
- body := substr (body, 2 , length(body) - 2 );
151
+ body := btrim (body, ' {} ' );
152
152
IF predicate IS NOT NULL THEN
153
153
predicates := predicates
154
154
|| graphql .format_comparison (tab,
@@ -185,8 +185,6 @@ BEGIN
185
185
sub .predicate ,
186
186
sub .body ,
187
187
tab);
188
- -- - TODO: Handle nested lookup into JSON, HStore, RECORD
189
- -- - TODO: If col REFERENCES something, push lookup down to it
190
188
cols := cols
191
189
|| name(format(' %I.%I' , ' sub/' || cardinality(subselects), col));
192
190
WHEN NOT FOUND THEN -- It might be a reference to another table
@@ -195,8 +193,9 @@ BEGIN
195
193
sub .body ,
196
194
tab);
197
195
cols := cols
198
- || name(format(' %I.%I' , ' sub/' || cardinality(subselects),
199
- sub .selector ));
196
+ || name(format(' %I.%I' ,
197
+ ' sub/' || cardinality(subselects),
198
+ sub .selector ));
200
199
ELSE
201
200
RAISE EXCEPTION ' Not able to interpret this selector: %' , sub .selector ;
202
201
END CASE;
@@ -214,7 +213,6 @@ BEGIN
214
213
ELSE
215
214
q := ' SELECT json_agg(' || column_expression || ' )' || q;
216
215
END IF;
217
- RAISE INFO ' Here: %' , q;
218
216
END;
219
217
q := q || format(E' \n FROM %I' , tab);
220
218
FOR i IN 1 ..cardinality(subselects) LOOP
@@ -249,7 +247,8 @@ DECLARE
249
247
lookups text [] = ARRAY[]::text [];
250
248
labels text [] = ARRAY[]::text [];
251
249
BEGIN
252
- SELECT col, typ FROM cols(tab) WHERE cols .col = selector INTO col, typ;
250
+ SELECT cols .col , cols .typ INTO col, typ
251
+ FROM graphql .cols (tab) WHERE cols .col = selector;
253
252
IF NOT FOUND THEN
254
253
RAISE EXCEPTION ' Did not find column % on table %' , col, tab;
255
254
END IF;
@@ -306,9 +305,9 @@ BEGIN
306
305
WHEN NO_DATA_FOUND THEN
307
306
RAISE EXCEPTION ' No REFERENCE to table % from table %' , tab, selector;
308
307
END;
309
- SELECT * FROM graphql .cols (selector)
310
- WHERE cols .col != ANY (SELECT array_agg (cols) FROM graphql .fk (selector))
311
- AND cols .typ NOT IN (regtype(' timestamp' ), regtype(' timestamptz' ));
308
+ PERFORM * FROM graphql .cols (selector)
309
+ WHERE cols .col NOT IN (SELECT unnest (cols) FROM graphql .fk (selector))
310
+ AND cols .typ NOT IN (regtype(' timestamp' ), regtype(' timestamptz' ));
312
311
-- - If:
313
312
-- - * Thare are two and only two foreign keys for the other table, and
314
313
-- - * All the columns of the table participate in one or the other
0 commit comments