{ "(repeated)": [ {"sql":"\n select ic.relname as name, am.amname as method, (i.indpred is not null) as partial, a.attname::text as column,\n pg_get_indexdef(i.indexrelid, k.ord::int, true) as definition, oc.opcname::text as opclass\n from pg_index i\n join pg_class ic on ic.oid = i.indexrelid\n join pg_am am on am.oid = ic.relam\n cross join lateral unnest(i.indkey::int2[], i.indclass::oid[]) with ordinality k(attnum, opclass, ord)\n left join pg_attribute a on a.attrelid = i.indrelid and a.attnum = k.attnum and k.attnum > 0\n join pg_opclass oc on oc.oid = k.opclass\n where i.indrelid = to_regclass($1) and i.indisvalid and i.indisready and k.ord <= i.indnkeyatts\n order by ic.relname, k.ord\n ","params":["\"customers\""],"result":{"command":"SELECT","rowCount":4,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[ ["customers_pkey","btree","f","id","id","int4_ops"], ["customers_region_idx","btree","f","region","region","text_ops"], ["customers_tenant_id_name_idx","btree","f","tenant_id","tenant_id","int4_ops"], ["customers_tenant_id_name_idx","btree","f","name","name","text_ops"] ]}} ], "(hooks)": { "(hooks)#0": [ {"sql":"\n create table customers (id integer primary key, tenant_id integer not null, region text not null, name text not null, email text not null, note text, deleted_at timestamptz);\n create index on customers (tenant_id, name);\n create index on customers (region);\n create table orders (id integer primary key, tenant_id integer not null, customer_id integer references customers, number text not null);\n create index on orders (customer_id);\n create table apps (id integer primary key, name text not null);\n create table app_runtimes (app_id integer primary key references apps, release text not null);\n create index on app_runtimes (release);\n insert into customers values\n (1, 1, 'east', 'Ada', 'ada@example.com', null, null), (2, 1, 'west', 'Bea', 'bea@example.com', null, null),\n (3, 1, 'east', 'Cy', 'cy@example.com', null, '2026-07-01'), (4, 2, 'east', 'Dee', 'dee@example.com', null, null);\n insert into orders values (1, 1, 2, 'A-1'), (2, 1, 1, 'A-2'), (3, 1, 3, 'A-3'), (4, 1, 4, 'A-4'), (5, 1, null, 'A-5');\n insert into apps values (1, 'shop'), (2, 'blog'), (3, 'wiki');\n insert into app_runtimes values (1, '2.0.0'), (2, '1.4.0');\n create table teams (id integer primary key);\n create table team_leads (id integer primary key, team_id integer not null references teams, name text not null);\n ","result":[{"command":"CREATE","rowCount":null,"columns":[],"rows":[]},{"command":"CREATE","rowCount":null,"columns":[],"rows":[]},{"command":"CREATE","rowCount":null,"columns":[],"rows":[]},{"command":"CREATE","rowCount":null,"columns":[],"rows":[]},{"command":"CREATE","rowCount":null,"columns":[],"rows":[]},{"command":"CREATE","rowCount":null,"columns":[],"rows":[]},{"command":"CREATE","rowCount":null,"columns":[],"rows":[]},{"command":"CREATE","rowCount":null,"columns":[],"rows":[]},{"command":"INSERT","rowCount":4,"columns":[],"rows":[]},{"command":"INSERT","rowCount":5,"columns":[],"rows":[]},{"command":"INSERT","rowCount":3,"columns":[],"rows":[]},{"command":"INSERT","rowCount":2,"columns":[],"rows":[]},{"command":"CREATE","rowCount":null,"columns":[],"rows":[]},{"command":"CREATE","rowCount":null,"columns":[],"rows":[]}]} ] }, "a lookup field through the record's own relation > shows the linked record's field, empty without a linked record the caller reads": { "(hooks)#0": [ {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"orders\""],"result":{"command":"SELECT","rowCount":1,"columns":[["relkind",18]],"rows":[["r"]]}}, {"sql":"\n select ic.relname as name, am.amname as method, (i.indpred is not null) as partial, a.attname::text as column,\n pg_get_indexdef(i.indexrelid, k.ord::int, true) as definition, oc.opcname::text as opclass\n from pg_index i\n join pg_class ic on ic.oid = i.indexrelid\n join pg_am am on am.oid = ic.relam\n cross join lateral unnest(i.indkey::int2[], i.indclass::oid[]) with ordinality k(attnum, opclass, ord)\n left join pg_attribute a on a.attrelid = i.indrelid and a.attnum = k.attnum and k.attnum > 0\n join pg_opclass oc on oc.oid = k.opclass\n where i.indrelid = to_regclass($1) and i.indisvalid and i.indisready and k.ord <= i.indnkeyatts\n order by ic.relname, k.ord\n ","params":["\"orders\""],"result":{"command":"SELECT","rowCount":2,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[ ["orders_customer_id_idx","btree","f","customer_id","customer_id","int4_ops"], ["orders_pkey","btree","f","id","id","int4_ops"] ]}}, {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"customers\""],"result":{"command":"SELECT","rowCount":1,"columns":[["relkind",18]],"rows":[["r"]]}}, {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"customers\""],"result":{"command":"SELECT","rowCount":1,"columns":[["relkind",18]],"rows":[["r"]]}}, {"repeated":0}, {"repeated":0}, {"sql":"start transaction read only","result":{"command":"START","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select set_config($1, $2, true)","params":["statement_timeout","1000"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25]],"rows":[["1s"]]}}, {"sql":"select \"t\".\"id\" as \"id\", \"t\".\"tenant_id\" as \"tenant_id\", \"t\".\"customer_id\" as \"customer_id\", \"t\".\"number\" as \"number\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"name\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $1) as l where l.k = \"t\".\"customer_id\") as \"customer_name\", \"t\".\"id\"::text as \"__pb_key0\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $2 order by \"t\".\"id\" asc limit $3","params":["1","1","51"],"result":{"command":"SELECT","rowCount":5,"columns":[["id",23],["tenant_id",23],["customer_id",23],["number",25],["customer_name",25],["__pb_key0",25]],"rows":[ ["1","1","2","A-1","Bea","1"], ["2","1","1","A-2","Ada","2"], ["3","1","3","A-3",null,"3"], ["4","1","4","A-4",null,"4"], ["5","1",null,"A-5",null,"5"] ]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $1","params":["1"],"result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Seq Scan\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"orders\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 24.12,\n \"Plan Rows\": 6,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Filter\": \"(t.tenant_id = 1)\"\n }\n }\n]"]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}}, {"sql":"start transaction read only","result":{"command":"START","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select set_config($1, $2, true)","params":["statement_timeout","1000"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25]],"rows":[["1s"]]}}, {"sql":"select \"t\".\"id\" as \"id\", \"t\".\"tenant_id\" as \"tenant_id\", \"t\".\"customer_id\" as \"customer_id\", \"t\".\"number\" as \"number\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"name\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $1 and \"t\".\"region\" = $2) as l where l.k = \"t\".\"customer_id\") as \"customer_name\", \"t\".\"id\"::text as \"__pb_key0\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $3 order by \"t\".\"id\" asc limit $4","params":["1","east","1","51"],"result":{"command":"SELECT","rowCount":5,"columns":[["id",23],["tenant_id",23],["customer_id",23],["number",25],["customer_name",25],["__pb_key0",25]],"rows":[ ["1","1","2","A-1",null,"1"], ["2","1","1","A-2","Ada","2"], ["3","1","3","A-3",null,"3"], ["4","1","4","A-4",null,"4"], ["5","1",null,"A-5",null,"5"] ]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $1","params":["1"],"result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Seq Scan\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"orders\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 24.12,\n \"Plan Rows\": 6,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Filter\": \"(t.tenant_id = 1)\"\n }\n }\n]"]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}}, {"sql":"start transaction read only","result":{"command":"START","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select set_config($1, $2, true)","params":["statement_timeout","1000"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25]],"rows":[["1s"]]}}, {"sql":"select \"id\" as \"id\", \"tenant_id\" as \"tenant_id\", \"customer_id\" as \"customer_id\", \"number\" as \"number\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"name\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $1) as l where l.k = \"t\".\"customer_id\") as \"customer_name\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"note\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2) as l where l.k = \"t\".\"customer_id\") as \"customer_note\" from \"orders\" as t where \"tenant_id\" = $3 and \"id\" = $4 limit 1","params":["1","1","1","1"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["customer_id",23],["number",25],["customer_name",25],["customer_note",25]],"rows":[["1","1","2","A-1","Bea",null]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a lookup field through the record's own relation > is filtered and sorted by the linked field, as the caller reads it": { "(hooks)#0": [ {"sql":"start transaction read only","result":{"command":"START","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select set_config($1, $2, true)","params":["statement_timeout","1000"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25]],"rows":[["1s"]]}}, {"sql":"select \"t\".\"id\" as \"id\", \"t\".\"tenant_id\" as \"tenant_id\", \"t\".\"customer_id\" as \"customer_id\", \"t\".\"number\" as \"number\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"name\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $1) as l where l.k = \"t\".\"customer_id\") as \"customer_name\", \"t\".\"id\"::text as \"__pb_key0\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $2 and (\"t\".\"customer_id\" is not null and \"t\".\"customer_id\" in (select \"t\".\"id\" from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and \"t\".\"name\" = $4)) order by \"t\".\"id\" asc limit $5","params":["1","1","1","Bea","51"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["customer_id",23],["number",25],["customer_name",25],["__pb_key0",25]],"rows":[["1","1","2","A-1","Bea","1"]]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"customer_id\" is not null and \"t\".\"customer_id\" in (select \"t\".\"id\" from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and \"t\".\"name\" = $3))","params":["1","1","Bea"],"result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Nested Loop\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Join Type\": \"Inner\",\n \"Startup Cost\": 4.36,\n \"Total Cost\": 21.87,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Inner Unique\": false,\n \"Plans\": [\n {\n \"Node Type\": \"Index Scan\",\n \"Parent Relationship\": \"Outer\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Scan Direction\": \"Forward\",\n \"Index Name\": \"customers_tenant_id_name_idx\",\n \"Relation Name\": \"customers\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 0.15,\n \"Total Cost\": 8.17,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\", \"t_1.tenant_id\", \"t_1.region\", \"t_1.name\", \"t_1.email\", \"t_1.note\", \"t_1.deleted_at\"],\n \"Index Cond\": \"((t_1.tenant_id = 1) AND (t_1.name = 'Bea'::text))\",\n \"Filter\": \"(t_1.deleted_at IS NULL)\"\n },\n {\n \"Node Type\": \"Bitmap Heap Scan\",\n \"Parent Relationship\": \"Inner\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"orders\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 4.21,\n \"Total Cost\": 13.70,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t.id\", \"t.tenant_id\", \"t.customer_id\", \"t.number\"],\n \"Recheck Cond\": \"((t.customer_id = t_1.id) AND (t.customer_id IS NOT NULL))\",\n \"Filter\": \"(t.tenant_id = 1)\",\n \"Plans\": [\n {\n \"Node Type\": \"Bitmap Index Scan\",\n \"Parent Relationship\": \"Outer\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Index Name\": \"orders_customer_id_idx\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 4.21,\n \"Plan Rows\": 6,\n \"Plan Width\": 0,\n \"Disabled\": false,\n \"Index Cond\": \"((t.customer_id = t_1.id) AND (t.customer_id IS NOT NULL))\"\n }\n ]\n }\n ]\n }\n }\n]"]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}}, {"sql":"start transaction read only","result":{"command":"START","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select set_config($1, $2, true)","params":["statement_timeout","1000"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25]],"rows":[["1s"]]}}, {"sql":"select \"t\".\"id\" as \"id\", \"t\".\"tenant_id\" as \"tenant_id\", \"t\".\"customer_id\" as \"customer_id\", \"t\".\"number\" as \"number\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"name\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $1 and \"t\".\"region\" = $2) as l where l.k = \"t\".\"customer_id\") as \"customer_name\", \"t\".\"id\"::text as \"__pb_key0\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $3 and (\"t\".\"customer_id\" is not null and \"t\".\"customer_id\" in (select \"t\".\"id\" from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $4 and \"t\".\"region\" = $5 and \"t\".\"name\" = $6)) order by \"t\".\"id\" asc limit $7","params":["1","east","1","1","east","Bea","51"],"result":{"command":"SELECT","rowCount":0,"columns":[["id",23],["tenant_id",23],["customer_id",23],["number",25],["customer_name",25],["__pb_key0",25]],"rows":[]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"customer_id\" is not null and \"t\".\"customer_id\" in (select \"t\".\"id\" from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and \"t\".\"region\" = $3 and \"t\".\"name\" = $4))","params":["1","1","east","Bea"],"result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Nested Loop\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Join Type\": \"Inner\",\n \"Startup Cost\": 4.36,\n \"Total Cost\": 21.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Inner Unique\": false,\n \"Plans\": [\n {\n \"Node Type\": \"Index Scan\",\n \"Parent Relationship\": \"Outer\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Scan Direction\": \"Forward\",\n \"Index Name\": \"customers_tenant_id_name_idx\",\n \"Relation Name\": \"customers\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 0.15,\n \"Total Cost\": 8.17,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\", \"t_1.tenant_id\", \"t_1.region\", \"t_1.name\", \"t_1.email\", \"t_1.note\", \"t_1.deleted_at\"],\n \"Index Cond\": \"((t_1.tenant_id = 1) AND (t_1.name = 'Bea'::text))\",\n \"Filter\": \"((t_1.deleted_at IS NULL) AND (t_1.region = 'east'::text))\"\n },\n {\n \"Node Type\": \"Bitmap Heap Scan\",\n \"Parent Relationship\": \"Inner\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"orders\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 4.21,\n \"Total Cost\": 13.70,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t.id\", \"t.tenant_id\", \"t.customer_id\", \"t.number\"],\n \"Recheck Cond\": \"((t.customer_id = t_1.id) AND (t.customer_id IS NOT NULL))\",\n \"Filter\": \"(t.tenant_id = 1)\",\n \"Plans\": [\n {\n \"Node Type\": \"Bitmap Index Scan\",\n \"Parent Relationship\": \"Outer\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Index Name\": \"orders_customer_id_idx\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 4.21,\n \"Plan Rows\": 6,\n \"Plan Width\": 0,\n \"Disabled\": false,\n \"Index Cond\": \"((t.customer_id = t_1.id) AND (t.customer_id IS NOT NULL))\"\n }\n ]\n }\n ]\n }\n }\n]"]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}}, {"sql":"start transaction read only","result":{"command":"START","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select set_config($1, $2, true)","params":["statement_timeout","1000"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25]],"rows":[["1s"]]}}, {"sql":"select \"t\".\"id\" as \"id\", \"t\".\"tenant_id\" as \"tenant_id\", \"t\".\"customer_id\" as \"customer_id\", \"t\".\"number\" as \"number\", \"t\".\"id\"::text as \"__pb_key0\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $1 and not (\"t\".\"customer_id\" is not null and \"t\".\"customer_id\" in (select \"t\".\"id\" from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and \"t\".\"region\" = $3 and \"t\".\"name\" is not null)) order by \"t\".\"id\" asc limit $4","params":["1","1","east","51"],"result":{"command":"SELECT","rowCount":4,"columns":[["id",23],["tenant_id",23],["customer_id",23],["number",25],["__pb_key0",25]],"rows":[ ["1","1","2","A-1","1"], ["3","1","3","A-3","3"], ["4","1","4","A-4","4"], ["5","1",null,"A-5","5"] ]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $1 and not (\"t\".\"customer_id\" is not null and \"t\".\"customer_id\" in (select \"t\".\"id\" from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and \"t\".\"region\" = $3 and \"t\".\"name\" is not null))","params":["1","1","east"],"result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Seq Scan\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"orders\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 12.19,\n \"Total Cost\": 39.14,\n \"Plan Rows\": 3,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Filter\": \"(((t.customer_id IS NULL) OR (NOT (ANY (t.customer_id = (hashed SubPlan 1).col1)))) AND (t.tenant_id = 1))\",\n \"Plans\": [\n {\n \"Node Type\": \"Index Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 1\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Scan Direction\": \"Forward\",\n \"Index Name\": \"customers_region_idx\",\n \"Relation Name\": \"customers\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 0.15,\n \"Total Cost\": 12.19,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\"],\n \"Index Cond\": \"(t_1.region = 'east'::text)\",\n \"Filter\": \"((t_1.deleted_at IS NULL) AND (t_1.tenant_id = 1))\"\n }\n ]\n }\n }\n]"]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}}, {"sql":"start transaction read only","result":{"command":"START","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select set_config($1, $2, true)","params":["statement_timeout","1000"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25]],"rows":[["1s"]]}}, {"sql":"select \"t\".\"id\" as \"id\", \"t\".\"tenant_id\" as \"tenant_id\", \"t\".\"customer_id\" as \"customer_id\", \"t\".\"number\" as \"number\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"name\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $1) as l where l.k = \"t\".\"customer_id\")::text as \"__pb_key0\", \"t\".\"id\"::text as \"__pb_key1\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $2 order by (select l.v from (select \"t\".\"id\" as k, \"t\".\"name\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3) as l where l.k = \"t\".\"customer_id\") asc nulls last, \"t\".\"id\" asc limit $4","params":["1","1","1","51"],"result":{"command":"SELECT","rowCount":5,"columns":[["id",23],["tenant_id",23],["customer_id",23],["number",25],["__pb_key0",25],["__pb_key1",25]],"rows":[ ["2","1","1","A-2","Ada","2"], ["1","1","2","A-1","Bea","1"], ["3","1","3","A-3",null,"3"], ["4","1","4","A-4",null,"4"], ["5","1",null,"A-5",null,"5"] ]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $1","params":["1"],"result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Seq Scan\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"orders\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 24.12,\n \"Plan Rows\": 6,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Filter\": \"(t.tenant_id = 1)\"\n }\n }\n]"]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a lookup field through the record's own relation > is not there for a caller who cannot read the linked field": { "(hooks)#0": [ {"sql":"start transaction read only","result":{"command":"START","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select set_config($1, $2, true)","params":["statement_timeout","1000"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25]],"rows":[["1s"]]}}, {"sql":"select \"t\".\"id\" as \"id\", \"t\".\"tenant_id\" as \"tenant_id\", \"t\".\"customer_id\" as \"customer_id\", \"t\".\"number\" as \"number\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"name\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $1) as l where l.k = \"t\".\"customer_id\") as \"customer_name\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"email\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2) as l where l.k = \"t\".\"customer_id\") as \"customer_email\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"note\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3) as l where l.k = \"t\".\"customer_id\") as \"customer_note\", \"t\".\"id\"::text as \"__pb_key0\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $4 and \"t\".\"id\" = $5 order by \"t\".\"id\" asc limit $6","params":["1","1","1","1","1","51"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["customer_id",23],["number",25],["customer_name",25],["customer_email",25],["customer_note",25],["__pb_key0",25]],"rows":[["1","1","2","A-1","Bea","bea@example.com",null,"1"]]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $1 and \"t\".\"id\" = $2","params":["1","1"],"result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Index Scan\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Scan Direction\": \"Forward\",\n \"Index Name\": \"orders_pkey\",\n \"Relation Name\": \"orders\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 0.15,\n \"Total Cost\": 8.17,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Index Cond\": \"(t.id = 1)\",\n \"Filter\": \"(t.tenant_id = 1)\"\n }\n }\n]"]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}}, {"sql":"start transaction read only","result":{"command":"START","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select set_config($1, $2, true)","params":["statement_timeout","1000"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25]],"rows":[["1s"]]}}, {"sql":"select \"t\".\"id\" as \"id\", \"t\".\"tenant_id\" as \"tenant_id\", \"t\".\"customer_id\" as \"customer_id\", \"t\".\"number\" as \"number\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"name\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $1) as l where l.k = \"t\".\"customer_id\") as \"customer_name\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"note\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2) as l where l.k = \"t\".\"customer_id\") as \"customer_note\", \"t\".\"id\"::text as \"__pb_key0\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $3 and \"t\".\"id\" = $4 order by \"t\".\"id\" asc limit $5","params":["1","1","1","1","51"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["customer_id",23],["number",25],["customer_name",25],["customer_note",25],["__pb_key0",25]],"rows":[["1","1","2","A-1","Bea",null,"1"]]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"orders\" as \"t\" where \"t\".\"tenant_id\" = $1 and \"t\".\"id\" = $2","params":["1","1"],"result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Index Scan\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Scan Direction\": \"Forward\",\n \"Index Name\": \"orders_pkey\",\n \"Relation Name\": \"orders\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 0.15,\n \"Total Cost\": 8.17,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Index Cond\": \"(t.id = 1)\",\n \"Filter\": \"(t.tenant_id = 1)\"\n }\n }\n]"]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a lookup field through the record's own relation > leaves the record's ETag to its own fields, and comes back from a write": { "(hooks)#0": [ {"sql":"start transaction read only","result":{"command":"START","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select set_config($1, $2, true)","params":["statement_timeout","1000"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25]],"rows":[["1s"]]}}, {"sql":"select \"id\" as \"id\", \"tenant_id\" as \"tenant_id\", \"customer_id\" as \"customer_id\", \"number\" as \"number\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"name\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $1) as l where l.k = \"t\".\"customer_id\") as \"customer_name\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"note\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2) as l where l.k = \"t\".\"customer_id\") as \"customer_note\" from \"orders\" as t where \"tenant_id\" = $3 and \"id\" = $4 limit 1","params":["1","1","1","1"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["customer_id",23],["number",25],["customer_name",25],["customer_note",25]],"rows":[["1","1","2","A-1","Bea",null]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}}, {"sql":"begin","result":{"command":"BEGIN","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select set_config($1, $2, true), pg_logical_emit_message(true, $3, $4::text) is not null","params":["statement_timeout","1000","protobase_actor","{\"id\":\"u1\",\"roles\":[\"member\"]}"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25],["?column?",16]],"rows":[["1s","t"]]}}, {"sql":"select \"id\" as \"id\", \"tenant_id\" as \"tenant_id\", \"customer_id\" as \"customer_id\", \"number\" as \"number\" from \"orders\" as t where \"tenant_id\" = $1 and \"id\" = $2 limit 1 for update","params":["1","1"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["customer_id",23],["number",25]],"rows":[["1","1","2","A-1"]]}}, {"sql":"update \"orders\" as t set \"number\" = $1 where \"tenant_id\" = $2 and \"id\" = $3 returning \"id\" as \"id\", \"tenant_id\" as \"tenant_id\", \"customer_id\" as \"customer_id\", \"number\" as \"number\"","params":["A-1b","1","1"],"result":{"command":"UPDATE","rowCount":1,"columns":[["id",23],["tenant_id",23],["customer_id",23],["number",25]],"rows":[["1","1","2","A-1b"]]}}, {"sql":"select (select l.v from (select \"t\".\"id\" as k, \"t\".\"name\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $1) as l where l.k = \"t\".\"customer_id\") as \"customer_name\", (select l.v from (select \"t\".\"id\" as k, \"t\".\"note\" as v from \"customers\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2) as l where l.k = \"t\".\"customer_id\") as \"customer_note\" from \"orders\" as t where \"tenant_id\" = $3 and \"id\" = $4 limit 1","params":["1","1","1","1"],"result":{"command":"SELECT","rowCount":1,"columns":[["customer_name",25],["customer_note",25]],"rows":[["Bea",null]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a lookup field of the one record of another resource that points at it > shows and sorts by that record's field, empty without one": { "(hooks)#0": [ {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"apps\""],"result":{"command":"SELECT","rowCount":1,"columns":[["relkind",18]],"rows":[["r"]]}}, {"sql":"\n select ic.relname as name, am.amname as method, (i.indpred is not null) as partial, a.attname::text as column,\n pg_get_indexdef(i.indexrelid, k.ord::int, true) as definition, oc.opcname::text as opclass\n from pg_index i\n join pg_class ic on ic.oid = i.indexrelid\n join pg_am am on am.oid = ic.relam\n cross join lateral unnest(i.indkey::int2[], i.indclass::oid[]) with ordinality k(attnum, opclass, ord)\n left join pg_attribute a on a.attrelid = i.indrelid and a.attnum = k.attnum and k.attnum > 0\n join pg_opclass oc on oc.oid = k.opclass\n where i.indrelid = to_regclass($1) and i.indisvalid and i.indisready and k.ord <= i.indnkeyatts\n order by ic.relname, k.ord\n ","params":["\"apps\""],"result":{"command":"SELECT","rowCount":1,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[["apps_pkey","btree","f","id","id","int4_ops"]]}}, {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"app_runtimes\""],"result":{"command":"SELECT","rowCount":1,"columns":[["relkind",18]],"rows":[["r"]]}}, {"sql":"\n select ic.relname as name, am.amname as method, (i.indpred is not null) as partial, a.attname::text as column,\n pg_get_indexdef(i.indexrelid, k.ord::int, true) as definition, oc.opcname::text as opclass\n from pg_index i\n join pg_class ic on ic.oid = i.indexrelid\n join pg_am am on am.oid = ic.relam\n cross join lateral unnest(i.indkey::int2[], i.indclass::oid[]) with ordinality k(attnum, opclass, ord)\n left join pg_attribute a on a.attrelid = i.indrelid and a.attnum = k.attnum and k.attnum > 0\n join pg_opclass oc on oc.oid = k.opclass\n where i.indrelid = to_regclass($1) and i.indisvalid and i.indisready and k.ord <= i.indnkeyatts\n order by ic.relname, k.ord\n ","params":["\"app_runtimes\""],"result":{"command":"SELECT","rowCount":2,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[ ["app_runtimes_pkey","btree","f","app_id","app_id","int4_ops"], ["app_runtimes_release_idx","btree","f","release","release","text_ops"] ]}}, {"sql":"start transaction read only","result":{"command":"START","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select set_config($1, $2, true)","params":["statement_timeout","1000"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25]],"rows":[["1s"]]}}, {"sql":"select \"t\".\"id\" as \"id\", \"t\".\"name\" as \"name\", (select l.v from (select \"t\".\"app_id\" as k, \"t\".\"release\" as v from \"app_runtimes\" as \"t\") as l where l.k = \"t\".\"id\") as \"release\", (select l.v from (select \"t\".\"app_id\" as k, \"t\".\"release\" as v from \"app_runtimes\" as \"t\") as l where l.k = \"t\".\"id\")::text as \"__pb_key0\", \"t\".\"id\"::text as \"__pb_key1\" from \"apps\" as \"t\" order by (select l.v from (select \"t\".\"app_id\" as k, \"t\".\"release\" as v from \"app_runtimes\" as \"t\") as l where l.k = \"t\".\"id\") desc nulls first, \"t\".\"id\" desc limit $1","params":["51"],"result":{"command":"SELECT","rowCount":3,"columns":[["id",23],["name",25],["release",25],["__pb_key0",25],["__pb_key1",25]],"rows":[ ["3","wiki",null,null,"3"], ["1","shop","2.0.0","2.0.0","1"], ["2","blog","1.4.0","1.4.0","2"] ]}}, {"sql":"select reltuples::float8 as reltuples from pg_class where oid = to_regclass($1)","params":["\"apps\""],"result":{"command":"SELECT","rowCount":1,"columns":[["reltuples",701]],"rows":[["-1"]]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"apps\" as \"t\"","result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Seq Scan\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"apps\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 22.70,\n \"Plan Rows\": 1270,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"]\n }\n }\n]"]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a lookup field of the one record of another resource that points at it > refuses a list whose linked records no index finds by the relation that points at them": { "(hooks)#0": [ {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"teams\""],"result":{"command":"SELECT","rowCount":1,"columns":[["relkind",18]],"rows":[["r"]]}}, {"sql":"\n select ic.relname as name, am.amname as method, (i.indpred is not null) as partial, a.attname::text as column,\n pg_get_indexdef(i.indexrelid, k.ord::int, true) as definition, oc.opcname::text as opclass\n from pg_index i\n join pg_class ic on ic.oid = i.indexrelid\n join pg_am am on am.oid = ic.relam\n cross join lateral unnest(i.indkey::int2[], i.indclass::oid[]) with ordinality k(attnum, opclass, ord)\n left join pg_attribute a on a.attrelid = i.indrelid and a.attnum = k.attnum and k.attnum > 0\n join pg_opclass oc on oc.oid = k.opclass\n where i.indrelid = to_regclass($1) and i.indisvalid and i.indisready and k.ord <= i.indnkeyatts\n order by ic.relname, k.ord\n ","params":["\"teams\""],"result":{"command":"SELECT","rowCount":1,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[["teams_pkey","btree","f","id","id","int4_ops"]]}}, {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"team_leads\""],"result":{"command":"SELECT","rowCount":1,"columns":[["relkind",18]],"rows":[["r"]]}}, {"sql":"\n select ic.relname as name, am.amname as method, (i.indpred is not null) as partial, a.attname::text as column,\n pg_get_indexdef(i.indexrelid, k.ord::int, true) as definition, oc.opcname::text as opclass\n from pg_index i\n join pg_class ic on ic.oid = i.indexrelid\n join pg_am am on am.oid = ic.relam\n cross join lateral unnest(i.indkey::int2[], i.indclass::oid[]) with ordinality k(attnum, opclass, ord)\n left join pg_attribute a on a.attrelid = i.indrelid and a.attnum = k.attnum and k.attnum > 0\n join pg_opclass oc on oc.oid = k.opclass\n where i.indrelid = to_regclass($1) and i.indisvalid and i.indisready and k.ord <= i.indnkeyatts\n order by ic.relname, k.ord\n ","params":["\"team_leads\""],"result":{"command":"SELECT","rowCount":1,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[["team_leads_pkey","btree","f","id","id","int4_ops"]]}} ] } }