{ "(repeated)": [ {"sql":"select \"t\".\"id\" as \"id\", \"t\".\"tenant_id\" as \"tenant_id\", \"t\".\"channel_id\" as \"channel_id\", \"t\".\"direct_message_id\" as \"direct_message_id\", \"t\".\"body\" as \"body\", \"t\".\"id\"::text as \"__pb_key0\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text)))) order by \"t\".\"id\" asc limit $9","params":["1","1","public","alice","alice","1","alice","alice","51"],"result":{"command":"SELECT","rowCount":4,"columns":[["id",23],["tenant_id",23],["channel_id",23],["direct_message_id",23],["body",25],["__pb_key0",25]],"rows":[ ["1","1","1",null,"hello all","1"], ["2","1","2",null,"secret plan","2"], ["5","1",null,"1","just us","5"], ["6","1",null,null,"no conversation","6"] ]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text))))","params":["1","1","public","alice","alice","1","alice","alice"],"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\": \"messages\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 60.88,\n \"Total Cost\": 89.61,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Filter\": \"(((t.channel_id IS NULL) OR (ANY (t.channel_id = (hashed SubPlan 1).col1))) AND ((t.direct_message_id IS NULL) OR (ANY (t.direct_message_id = (hashed SubPlan 2).col1))) AND (t.tenant_id = 1))\",\n \"Plans\": [\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 1\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"channels\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 26.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\"],\n \"Filter\": \"((t_1.deleted_at IS NULL) AND (t_1.tenant_id = 1) AND ((t_1.kind = 'public'::text) OR jsonb_exists(t_1.member_ids, 'alice'::text) OR (t_1.member_ids @> to_jsonb('alice'::text))))\"\n },\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 2\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"direct_messages\",\n \"Schema\": \"public\",\n \"Alias\": \"t_2\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 34.00,\n \"Plan Rows\": 2,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_2.id\"],\n \"Filter\": \"((t_2.tenant_id = 1) AND (jsonb_exists(t_2.member_ids, 'alice'::text) OR (t_2.member_ids @> to_jsonb('alice'::text))))\"\n }\n ]\n }\n }\n]"]]}}, {"sql":"select \"t\".\"id\" as \"id\", \"t\".\"tenant_id\" as \"tenant_id\", \"t\".\"channel_id\" as \"channel_id\", \"t\".\"direct_message_id\" as \"direct_message_id\", \"t\".\"body\" as \"body\", \"t\".\"id\"::text as \"__pb_key0\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text)))) order by \"t\".\"id\" asc limit $9","params":["1","1","public","bob","bob","1","bob","bob","51"],"result":{"command":"SELECT","rowCount":3,"columns":[["id",23],["tenant_id",23],["channel_id",23],["direct_message_id",23],["body",25],["__pb_key0",25]],"rows":[ ["1","1","1",null,"hello all","1"], ["5","1",null,"1","just us","5"], ["6","1",null,null,"no conversation","6"] ]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text))))","params":["1","1","public","bob","bob","1","bob","bob"],"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\": \"messages\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 60.88,\n \"Total Cost\": 89.61,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Filter\": \"(((t.channel_id IS NULL) OR (ANY (t.channel_id = (hashed SubPlan 1).col1))) AND ((t.direct_message_id IS NULL) OR (ANY (t.direct_message_id = (hashed SubPlan 2).col1))) AND (t.tenant_id = 1))\",\n \"Plans\": [\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 1\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"channels\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 26.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\"],\n \"Filter\": \"((t_1.deleted_at IS NULL) AND (t_1.tenant_id = 1) AND ((t_1.kind = 'public'::text) OR jsonb_exists(t_1.member_ids, 'bob'::text) OR (t_1.member_ids @> to_jsonb('bob'::text))))\"\n },\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 2\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"direct_messages\",\n \"Schema\": \"public\",\n \"Alias\": \"t_2\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 34.00,\n \"Plan Rows\": 2,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_2.id\"],\n \"Filter\": \"((t_2.tenant_id = 1) AND (jsonb_exists(t_2.member_ids, 'bob'::text) OR (t_2.member_ids @> to_jsonb('bob'::text))))\"\n }\n ]\n }\n }\n]"]]}}, {"sql":"select \"id\" as \"id\", \"tenant_id\" as \"tenant_id\", \"channel_id\" as \"channel_id\", \"thread_id\" as \"thread_id\", \"body\" as \"body\" from \"replies\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $3 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $4 and (\"t\".\"kind\" = $5 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $6) or \"t\".\"member_ids\"::jsonb @> to_jsonb($7::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $8 and (\"t\".\"kind\" = $9 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $10) or \"t\".\"member_ids\"::jsonb @> to_jsonb($11::text))))) limit 1","params":["1","1","1","1","public","alice","alice","1","public","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["channel_id",23],["thread_id",23],["body",25]],"rows":[["1","1","2",null,"private thread"]]}}, {"sql":"select \"id\" as \"id\", \"tenant_id\" as \"tenant_id\", \"channel_id\" as \"channel_id\", \"thread_id\" as \"thread_id\", \"body\" as \"body\" from \"replies\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $3 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $4 and (\"t\".\"kind\" = $5 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $6) or \"t\".\"member_ids\"::jsonb @> to_jsonb($7::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $8 and (\"t\".\"kind\" = $9 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $10) or \"t\".\"member_ids\"::jsonb @> to_jsonb($11::text))))) limit 1 for no key update","params":["1","1","1","1","public","alice","alice","1","public","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["channel_id",23],["thread_id",23],["body",25]],"rows":[["1","1","2",null,"private thread"]]}} ], "(hooks)": { "(hooks)#0": [ {"sql":"\n create table channels (id integer primary key, tenant_id integer not null, kind text not null, member_ids jsonb not null, deleted_at timestamptz);\n create index on channels using gin (member_ids);\n create index on channels (kind);\n create table direct_messages (id integer primary key, tenant_id integer not null, member_ids jsonb not null);\n create index on direct_messages using gin (member_ids);\n create table messages (id integer primary key, tenant_id integer not null, channel_id integer references channels, direct_message_id integer references direct_messages, body text not null);\n create index on messages (id);\n create index on messages (channel_id);\n create index on messages (direct_message_id);\n create index on messages (body);\n create extension if not exists pg_trgm;\n create index on messages using gin (body gin_trgm_ops);\n create table reactions (id integer primary key, message_id integer not null references messages, emoji text not null);\n create table pins (id integer primary key, channel_id integer not null references channels);\n create table rooms (id integer primary key, open boolean not null);\n create table posts (id integer primary key, room_id integer references rooms);\n create index on posts (room_id);\n create table folders (id integer primary key, owner_id text not null, parent_id integer references folders);\n create index on folders (owner_id);\n create index on folders (parent_id);\n create table replies (id integer primary key, tenant_id integer not null, channel_id integer references channels, thread_id integer references replies, body text not null);\n create index on replies (id);\n create index on replies (channel_id);\n create index on replies (thread_id);\n create index on replies (body);\n create index on replies using gin (body gin_trgm_ops);\n insert into channels values\n (1, 1, 'public', '[]', null), (2, 1, 'private', '[\"alice\"]', null), (3, 1, 'private', '[\"alice\", \"bob\"]', '2026-07-01'),\n (4, 2, 'public', '[]', null);\n insert into direct_messages values (1, 1, '[\"alice\", \"bob\"]');\n insert into messages values\n (1, 1, 1, null, 'hello all'), (2, 1, 2, null, 'secret plan'), (3, 1, 3, null, 'gone channel'),\n (4, 1, 4, null, 'other workspace'), (5, 1, null, 1, 'just us'), (6, 1, null, null, 'no conversation');\n insert into reactions values (1, 1, 'wave'), (2, 2, 'eyes');\n insert into pins values (1, 1);\n insert into rooms values (1, true), (2, false);\n insert into posts values (1, 1), (2, 2), (3, null);\n insert into folders values (1, 'alice', null), (2, 'alice', 1), (3, 'bob', null), (4, 'alice', 3);\n insert into replies values (1, 1, 2, null, 'private thread'), (2, 1, null, 1, 'private reply');\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":"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":"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":"CREATE","rowCount":null,"columns":[],"rows":[]},{"command":"CREATE","rowCount":null,"columns":[],"rows":[]},{"command":"INSERT","rowCount":4,"columns":[],"rows":[]},{"command":"INSERT","rowCount":1,"columns":[],"rows":[]},{"command":"INSERT","rowCount":6,"columns":[],"rows":[]},{"command":"INSERT","rowCount":2,"columns":[],"rows":[]},{"command":"INSERT","rowCount":1,"columns":[],"rows":[]},{"command":"INSERT","rowCount":2,"columns":[],"rows":[]},{"command":"INSERT","rowCount":3,"columns":[],"rows":[]},{"command":"INSERT","rowCount":4,"columns":[],"rows":[]},{"command":"INSERT","rowCount":2,"columns":[],"rows":[]}]} ] }, "a child under .parent(fk, \"read\") > lists only the messages of conversations the caller reads, a message naming none included": { "(hooks)#0": [ {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"messages\""],"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":["\"messages\""],"result":{"command":"SELECT","rowCount":6,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[ ["messages_body_idx","btree","f","body","body","text_ops"], ["messages_body_idx1","gin","f","body","body","gin_trgm_ops"], ["messages_channel_id_idx","btree","f","channel_id","channel_id","int4_ops"], ["messages_direct_message_id_idx","btree","f","direct_message_id","direct_message_id","int4_ops"], ["messages_id_idx","btree","f","id","id","int4_ops"], ["messages_pkey","btree","f","id","id","int4_ops"] ]}}, {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"channels\""],"result":{"command":"SELECT","rowCount":1,"columns":[["relkind",18]],"rows":[["r"]]}}, {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"direct_messages\""],"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":["\"channels\""],"result":{"command":"SELECT","rowCount":3,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[ ["channels_kind_idx","btree","f","kind","kind","text_ops"], ["channels_member_ids_idx","gin","f","member_ids","member_ids","jsonb_ops"], ["channels_pkey","btree","f","id","id","int4_ops"] ]}}, {"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":["\"direct_messages\""],"result":{"command":"SELECT","rowCount":2,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[ ["direct_messages_member_ids_idx","gin","f","member_ids","member_ids","jsonb_ops"], ["direct_messages_pkey","btree","f","id","id","int4_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"]]}}, {"repeated":0}, {"repeated":1}, {"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\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\" from \"messages\" as t where \"tenant_id\" = $1 and (\"id\") in (($2), ($3), ($4), ($5))","params":["1","1","2","5","6"],"result":{"command":"SELECT","rowCount":4,"columns":[["id",23],["channel_id",23],["direct_message_id",23]],"rows":[ ["1","1",null], ["2","2",null], ["5",null,"1"], ["6",null,null] ]}}, {"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\", \"kind\" as \"kind\", \"member_ids\" as \"member_ids\", \"deleted_at\" as \"deleted_at\" from \"channels\" as t where \"deleted_at\" is null and \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))) limit 1","params":["1","1","public","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["kind",25],["member_ids",3802],["deleted_at",1184]],"rows":[["1","1","public","[]",null]]}}, {"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\", \"kind\" as \"kind\", \"member_ids\" as \"member_ids\", \"deleted_at\" as \"deleted_at\" from \"channels\" as t where \"deleted_at\" is null and \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))) limit 1","params":["1","2","public","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["kind",25],["member_ids",3802],["deleted_at",1184]],"rows":[["2","1","private","[\"alice\"]",null]]}}, {"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\", \"member_ids\" as \"member_ids\" from \"direct_messages\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $3) or \"t\".\"member_ids\"::jsonb @> to_jsonb($4::text)) limit 1","params":["1","1","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["member_ids",3802]],"rows":[["1","1","[\"alice\", \"bob\"]"]]}}, {"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"]]}}, {"repeated":2}, {"repeated":3}, {"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\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\" from \"messages\" as t where \"tenant_id\" = $1 and (\"id\") in (($2), ($3), ($4))","params":["1","1","5","6"],"result":{"command":"SELECT","rowCount":3,"columns":[["id",23],["channel_id",23],["direct_message_id",23]],"rows":[ ["1","1",null], ["5",null,"1"], ["6",null,null] ]}}, {"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\", \"kind\" as \"kind\", \"member_ids\" as \"member_ids\", \"deleted_at\" as \"deleted_at\" from \"channels\" as t where \"deleted_at\" is null and \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))) limit 1","params":["1","1","public","bob","bob"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["kind",25],["member_ids",3802],["deleted_at",1184]],"rows":[["1","1","public","[]",null]]}}, {"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\", \"member_ids\" as \"member_ids\" from \"direct_messages\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $3) or \"t\".\"member_ids\"::jsonb @> to_jsonb($4::text)) limit 1","params":["1","1","bob","bob"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["member_ids",3802]],"rows":[["1","1","[\"alice\", \"bob\"]"]]}}, {"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\".\"channel_id\" as \"channel_id\", \"t\".\"direct_message_id\" as \"direct_message_id\", \"t\".\"body\" as \"body\", \"t\".\"id\"::text as \"__pb_key0\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text)))) order by \"t\".\"id\" asc limit $9","params":["1","1","public","carol","carol","1","carol","carol","51"],"result":{"command":"SELECT","rowCount":2,"columns":[["id",23],["tenant_id",23],["channel_id",23],["direct_message_id",23],["body",25],["__pb_key0",25]],"rows":[ ["1","1","1",null,"hello all","1"], ["6","1",null,null,"no conversation","6"] ]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text))))","params":["1","1","public","carol","carol","1","carol","carol"],"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\": \"messages\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 60.88,\n \"Total Cost\": 89.61,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Filter\": \"(((t.channel_id IS NULL) OR (ANY (t.channel_id = (hashed SubPlan 1).col1))) AND ((t.direct_message_id IS NULL) OR (ANY (t.direct_message_id = (hashed SubPlan 2).col1))) AND (t.tenant_id = 1))\",\n \"Plans\": [\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 1\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"channels\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 26.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\"],\n \"Filter\": \"((t_1.deleted_at IS NULL) AND (t_1.tenant_id = 1) AND ((t_1.kind = 'public'::text) OR jsonb_exists(t_1.member_ids, 'carol'::text) OR (t_1.member_ids @> to_jsonb('carol'::text))))\"\n },\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 2\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"direct_messages\",\n \"Schema\": \"public\",\n \"Alias\": \"t_2\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 34.00,\n \"Plan Rows\": 2,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_2.id\"],\n \"Filter\": \"((t_2.tenant_id = 1) AND (jsonb_exists(t_2.member_ids, 'carol'::text) OR (t_2.member_ids @> to_jsonb('carol'::text))))\"\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 \"id\" as \"id\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\" from \"messages\" as t where \"tenant_id\" = $1 and (\"id\") in (($2), ($3))","params":["1","1","6"],"result":{"command":"SELECT","rowCount":2,"columns":[["id",23],["channel_id",23],["direct_message_id",23]],"rows":[ ["1","1",null], ["6",null,null] ]}}, {"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\", \"kind\" as \"kind\", \"member_ids\" as \"member_ids\", \"deleted_at\" as \"deleted_at\" from \"channels\" as t where \"deleted_at\" is null and \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))) limit 1","params":["1","1","public","carol","carol"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["kind",25],["member_ids",3802],["deleted_at",1184]],"rows":[["1","1","public","[]",null]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a child under .parent(fk, \"read\") > answers a get outside them with 404, as other row filters do": { "(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\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\", \"body\" as \"body\" from \"messages\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $7 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $8) or \"t\".\"member_ids\"::jsonb @> to_jsonb($9::text)))) limit 1","params":["1","2","1","public","alice","alice","1","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["channel_id",23],["direct_message_id",23],["body",25]],"rows":[["2","1","2",null,"secret plan"]]}}, {"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\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\" from \"messages\" as t where \"tenant_id\" = $1 and (\"id\") in (($2))","params":["1","2"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["channel_id",23],["direct_message_id",23]],"rows":[["2","2",null]]}}, {"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\", \"kind\" as \"kind\", \"member_ids\" as \"member_ids\", \"deleted_at\" as \"deleted_at\" from \"channels\" as t where \"deleted_at\" is null and \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))) limit 1","params":["1","2","public","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["kind",25],["member_ids",3802],["deleted_at",1184]],"rows":[["2","1","private","[\"alice\"]",null]]}}, {"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\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\", \"body\" as \"body\" from \"messages\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $7 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $8) or \"t\".\"member_ids\"::jsonb @> to_jsonb($9::text)))) limit 1","params":["1","2","1","public","bob","bob","1","bob","bob"],"result":{"command":"SELECT","rowCount":0,"columns":[["id",23],["tenant_id",23],["channel_id",23],["direct_message_id",23],["body",25]],"rows":[]}}, {"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\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\", \"body\" as \"body\" from \"messages\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $7 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $8) or \"t\".\"member_ids\"::jsonb @> to_jsonb($9::text)))) limit 1","params":["1","5","1","public","carol","carol","1","carol","carol"],"result":{"command":"SELECT","rowCount":0,"columns":[["id",23],["tenant_id",23],["channel_id",23],["direct_message_id",23],["body",25]],"rows":[]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a child under .parent(fk, \"read\") > hides the messages of a soft-deleted channel and of a channel in another workspace": { "(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\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\", \"body\" as \"body\" from \"messages\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $7 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $8) or \"t\".\"member_ids\"::jsonb @> to_jsonb($9::text)))) limit 1","params":["1","3","1","public","alice","alice","1","alice","alice"],"result":{"command":"SELECT","rowCount":0,"columns":[["id",23],["tenant_id",23],["channel_id",23],["direct_message_id",23],["body",25]],"rows":[]}}, {"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\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\", \"body\" as \"body\" from \"messages\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $7 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $8) or \"t\".\"member_ids\"::jsonb @> to_jsonb($9::text)))) limit 1","params":["1","4","1","public","alice","alice","1","alice","alice"],"result":{"command":"SELECT","rowCount":0,"columns":[["id",23],["tenant_id",23],["channel_id",23],["direct_message_id",23],["body",25]],"rows":[]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a child under .parent(fk, \"read\") > narrows :search, :seek, counts, aggregates and labels the same way": { "(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\".\"channel_id\" as \"channel_id\", \"t\".\"direct_message_id\" as \"direct_message_id\", \"t\".\"body\" as \"body\", \"t\".\"id\"::text as \"__pb_key0\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text)))) and ((((\"t\".\"body\"::text is not null and \"t\".\"body\"::text ilike $9))) or (((\"t\".\"body\"::text is not null and \"t\".\"body\"::text ilike $10)))) order by \"t\".\"id\" asc limit $11","params":["1","1","public","bob","bob","1","bob","bob","%plan%","%hello%","51"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["channel_id",23],["direct_message_id",23],["body",25],["__pb_key0",25]],"rows":[["1","1","1",null,"hello all","1"]]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text)))) and ((((\"t\".\"body\"::text is not null and \"t\".\"body\"::text ilike $9))) or (((\"t\".\"body\"::text is not null and \"t\".\"body\"::text ilike $10))))","params":["1","1","public","bob","bob","1","bob","bob","%plan%","%hello%"],"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\": \"messages\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 60.88,\n \"Total Cost\": 94.96,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Filter\": \"(((t.channel_id IS NULL) OR (ANY (t.channel_id = (hashed SubPlan 1).col1))) AND ((t.direct_message_id IS NULL) OR (ANY (t.direct_message_id = (hashed SubPlan 2).col1))) AND (t.tenant_id = 1) AND ((t.body ~~* '%plan%'::text) OR (t.body ~~* '%hello%'::text)))\",\n \"Plans\": [\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 1\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"channels\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 26.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\"],\n \"Filter\": \"((t_1.deleted_at IS NULL) AND (t_1.tenant_id = 1) AND ((t_1.kind = 'public'::text) OR jsonb_exists(t_1.member_ids, 'bob'::text) OR (t_1.member_ids @> to_jsonb('bob'::text))))\"\n },\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 2\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"direct_messages\",\n \"Schema\": \"public\",\n \"Alias\": \"t_2\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 34.00,\n \"Plan Rows\": 2,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_2.id\"],\n \"Filter\": \"((t_2.tenant_id = 1) AND (jsonb_exists(t_2.member_ids, 'bob'::text) OR (t_2.member_ids @> to_jsonb('bob'::text))))\"\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 \"id\" as \"id\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\" from \"messages\" as t where \"tenant_id\" = $1 and (\"id\") in (($2))","params":["1","1"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["channel_id",23],["direct_message_id",23]],"rows":[["1","1",null]]}}, {"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\", \"kind\" as \"kind\", \"member_ids\" as \"member_ids\", \"deleted_at\" as \"deleted_at\" from \"channels\" as t where \"deleted_at\" is null and \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))) limit 1","params":["1","1","public","bob","bob"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["kind",25],["member_ids",3802],["deleted_at",1184]],"rows":[["1","1","public","[]",null]]}}, {"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"]]}}, {"repeated":3}, {"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"]]}}, {"repeated":3}, {"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 count(*)::text as \"n\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text))))","params":["1","1","public","bob","bob","1","bob","bob"],"result":{"command":"SELECT","rowCount":1,"columns":[["n",25]],"rows":[["3"]]}}, {"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 r.k0 as \"value\", r.rn::text as \"rn\" from (select \"t\".\"id\"::text as \"k0\", row_number() over (order by \"t\".\"id\" asc) as \"rn\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text))))) as \"r\" where (r.rn - 1) % $9 = 0 order by r.rn","params":["1","1","public","bob","bob","1","bob","bob","1"],"result":{"command":"SELECT","rowCount":3,"columns":[["value",25],["rn",25]],"rows":[ ["1","1"], ["5","2"], ["6","3"] ]}}, {"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"]]}}, {"repeated":2}, {"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\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\" from \"messages\" as t where \"tenant_id\" = $1 and (\"id\") in (($2), ($3), ($4))","params":["1","1","5","6"],"result":{"command":"SELECT","rowCount":3,"columns":[["id",23],["channel_id",23],["direct_message_id",23]],"rows":[ ["1","1",null], ["5",null,"1"], ["6",null,null] ]}}, {"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\", \"kind\" as \"kind\", \"member_ids\" as \"member_ids\", \"deleted_at\" as \"deleted_at\" from \"channels\" as t where \"deleted_at\" is null and \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))) limit 1","params":["1","1","public","bob","bob"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["kind",25],["member_ids",3802],["deleted_at",1184]],"rows":[["1","1","public","[]",null]]}}, {"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\", \"member_ids\" as \"member_ids\" from \"direct_messages\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $3) or \"t\".\"member_ids\"::jsonb @> to_jsonb($4::text)) limit 1","params":["1","1","bob","bob"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["member_ids",3802]],"rows":[["1","1","[\"alice\", \"bob\"]"]]}}, {"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\".\"channel_id\" as \"value\", count(*)::text as \"n\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text)))) group by \"t\".\"channel_id\" order by count(*) desc, \"t\".\"channel_id\" asc limit $9","params":["1","1","public","bob","bob","1","bob","bob","100"],"result":{"command":"SELECT","rowCount":2,"columns":[["value",23],["n",25]],"rows":[ [null,"2"], ["1","1"] ]}}, {"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\".\"channel_id\" as \"value\", count(*)::text as \"n\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text)))) group by \"t\".\"channel_id\" order by count(*) desc, \"t\".\"channel_id\" asc limit $9","params":["1","1","public","alice","alice","1","alice","alice","100"],"result":{"command":"SELECT","rowCount":3,"columns":[["value",23],["n",25]],"rows":[ [null,"2"], ["1","1"], ["2","1"] ]}}, {"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\".\"channel_id\" as \"value\", count(*)::text as \"n\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text)))) group by \"t\".\"channel_id\" order by count(*) desc, \"t\".\"channel_id\" asc limit $9","params":["1","1","public","bob","bob","1","bob","bob","100"],"result":{"command":"SELECT","rowCount":2,"columns":[["value",23],["n",25]],"rows":[ [null,"2"], ["1","1"] ]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}}, {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"reactions\""],"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":["\"reactions\""],"result":{"command":"SELECT","rowCount":1,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[["reactions_pkey","btree","f","id","id","int4_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\".\"message_id\" as \"message_id\", \"t\".\"emoji\" as \"emoji\", \"t\".\"id\"::text as \"__pb_key0\" from \"reactions\" as \"t\" order by \"t\".\"id\" asc limit $1","params":["51"],"result":{"command":"SELECT","rowCount":2,"columns":[["id",23],["message_id",23],["emoji",25],["__pb_key0",25]],"rows":[ ["1","1","wave","1"], ["2","2","eyes","2"] ]}}, {"sql":"select reltuples::float8 as reltuples from pg_class where oid = to_regclass($1)","params":["\"reactions\""],"result":{"command":"SELECT","rowCount":1,"columns":[["reltuples",701]],"rows":[["-1"]]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"reactions\" 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\": \"reactions\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 22.00,\n \"Plan Rows\": 1200,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"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\".\"body\" as \"body\", \"t\".\"id\"::text as \"__pb_key0\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text)))) and \"t\".\"id\" in ($9, $10) order by \"t\".\"id\" asc limit $11","params":["1","1","public","bob","bob","1","bob","bob","1","2","3"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["body",25],["__pb_key0",25]],"rows":[["1","hello all","1"]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a child under .parent(fk, \"read\") > hides them once the caller leaves the channel, and shows them again when they are back": { "(hooks)#0": [ {"sql":"update channels set member_ids = '[]' where id = 2","result":{"command":"UPDATE","rowCount":1,"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\".\"channel_id\" as \"channel_id\", \"t\".\"direct_message_id\" as \"direct_message_id\", \"t\".\"body\" as \"body\", \"t\".\"id\"::text as \"__pb_key0\" from \"messages\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))))) and (\"t\".\"direct_message_id\" is null or \"t\".\"direct_message_id\" in (select \"t\".\"id\" from \"direct_messages\" as \"t\" where \"t\".\"tenant_id\" = $6 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $7) or \"t\".\"member_ids\"::jsonb @> to_jsonb($8::text)))) order by \"t\".\"id\" asc limit $9","params":["1","1","public","alice","alice","1","alice","alice","51"],"result":{"command":"SELECT","rowCount":3,"columns":[["id",23],["tenant_id",23],["channel_id",23],["direct_message_id",23],["body",25],["__pb_key0",25]],"rows":[ ["1","1","1",null,"hello all","1"], ["5","1",null,"1","just us","5"], ["6","1",null,null,"no conversation","6"] ]}}, {"repeated":1}, {"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\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\" from \"messages\" as t where \"tenant_id\" = $1 and (\"id\") in (($2), ($3), ($4))","params":["1","1","5","6"],"result":{"command":"SELECT","rowCount":3,"columns":[["id",23],["channel_id",23],["direct_message_id",23]],"rows":[ ["1","1",null], ["5",null,"1"], ["6",null,null] ]}}, {"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\", \"kind\" as \"kind\", \"member_ids\" as \"member_ids\", \"deleted_at\" as \"deleted_at\" from \"channels\" as t where \"deleted_at\" is null and \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))) limit 1","params":["1","1","public","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["kind",25],["member_ids",3802],["deleted_at",1184]],"rows":[["1","1","public","[]",null]]}}, {"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\", \"member_ids\" as \"member_ids\" from \"direct_messages\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $3) or \"t\".\"member_ids\"::jsonb @> to_jsonb($4::text)) limit 1","params":["1","1","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["member_ids",3802]],"rows":[["1","1","[\"alice\", \"bob\"]"]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}}, {"sql":"update channels set member_ids = '[\"alice\"]' where id = 2","result":{"command":"UPDATE","rowCount":1,"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"]]}}, {"repeated":0}, {"repeated":1}, {"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\", \"channel_id\" as \"channel_id\", \"direct_message_id\" as \"direct_message_id\" from \"messages\" as t where \"tenant_id\" = $1 and (\"id\") in (($2), ($3), ($4), ($5))","params":["1","1","2","5","6"],"result":{"command":"SELECT","rowCount":4,"columns":[["id",23],["channel_id",23],["direct_message_id",23]],"rows":[ ["1","1",null], ["2","2",null], ["5",null,"1"], ["6",null,null] ]}}, {"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\", \"kind\" as \"kind\", \"member_ids\" as \"member_ids\", \"deleted_at\" as \"deleted_at\" from \"channels\" as t where \"deleted_at\" is null and \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))) limit 1","params":["1","1","public","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["kind",25],["member_ids",3802],["deleted_at",1184]],"rows":[["1","1","public","[]",null]]}}, {"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\", \"kind\" as \"kind\", \"member_ids\" as \"member_ids\", \"deleted_at\" as \"deleted_at\" from \"channels\" as t where \"deleted_at\" is null and \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))) limit 1","params":["1","2","public","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["kind",25],["member_ids",3802],["deleted_at",1184]],"rows":[["2","1","private","[\"alice\"]",null]]}}, {"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\", \"member_ids\" as \"member_ids\" from \"direct_messages\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (jsonb_exists(\"t\".\"member_ids\"::jsonb, $3) or \"t\".\"member_ids\"::jsonb @> to_jsonb($4::text)) limit 1","params":["1","1","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["member_ids",3802]],"rows":[["1","1","[\"alice\", \"bob\"]"]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a child under .parent(fk, \"read\") > refuses a list whose relation to the parent no index serves": { "(hooks)#0": [ {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"pins\""],"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":["\"pins\""],"result":{"command":"SELECT","rowCount":1,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[["pins_pkey","btree","f","id","id","int4_ops"]]}} ] }, "a child under .parent(fk, \"read\") > shows only the children naming no parent when the parent read rule reads the record": { "(hooks)#0": [ {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"posts\""],"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":["\"posts\""],"result":{"command":"SELECT","rowCount":2,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[ ["posts_pkey","btree","f","id","id","int4_ops"], ["posts_room_id_idx","btree","f","room_id","room_id","int4_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\".\"room_id\" as \"room_id\", \"t\".\"id\"::text as \"__pb_key0\" from \"posts\" as \"t\" where (\"t\".\"room_id\" is null or false) order by \"t\".\"id\" asc limit $1","params":["51"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["room_id",23],["__pb_key0",25]],"rows":[["3",null,"3"]]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"posts\" as \"t\" where (\"t\".\"room_id\" is null or false)","result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Bitmap Heap Scan\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"posts\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 4.24,\n \"Total Cost\": 14.88,\n \"Plan Rows\": 11,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Recheck Cond\": \"(t.room_id IS NULL)\",\n \"Plans\": [\n {\n \"Node Type\": \"Bitmap Index Scan\",\n \"Parent Relationship\": \"Outer\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Index Name\": \"posts_room_id_idx\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 4.24,\n \"Plan Rows\": 11,\n \"Plan Width\": 0,\n \"Disabled\": false,\n \"Index Cond\": \"(t.room_id IS NULL)\"\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 \"id\" as \"id\", \"room_id\" as \"room_id\" from \"posts\" as t where (\"id\") in (($1))","params":["3"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["room_id",23]],"rows":[["3",null]]}}, {"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\", \"room_id\" as \"room_id\" from \"posts\" as t where \"id\" = $1 and (\"t\".\"room_id\" is null or false) limit 1","params":["1"],"result":{"command":"SELECT","rowCount":0,"columns":[["id",23],["room_id",23]],"rows":[]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a child under .parent(fk, \"read\") > checks a resource that is its own parent one level up": { "(hooks)#0": [ {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"folders\""],"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":["\"folders\""],"result":{"command":"SELECT","rowCount":3,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[ ["folders_owner_id_idx","btree","f","owner_id","owner_id","text_ops"], ["folders_parent_id_idx","btree","f","parent_id","parent_id","int4_ops"], ["folders_pkey","btree","f","id","id","int4_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\".\"owner_id\" as \"owner_id\", \"t\".\"parent_id\" as \"parent_id\", \"t\".\"id\"::text as \"__pb_key0\" from \"folders\" as \"t\" where \"t\".\"owner_id\" = $1 and (\"t\".\"parent_id\" is null or \"t\".\"parent_id\" in (select \"t\".\"id\" from \"folders\" as \"t\" where \"t\".\"owner_id\" = $2)) order by \"t\".\"id\" asc limit $3","params":["alice","alice","51"],"result":{"command":"SELECT","rowCount":2,"columns":[["id",23],["owner_id",25],["parent_id",23],["__pb_key0",25]],"rows":[ ["1","alice",null,"1"], ["2","alice","1","2"] ]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"folders\" as \"t\" where \"t\".\"owner_id\" = $1 and (\"t\".\"parent_id\" is null or \"t\".\"parent_id\" in (select \"t\".\"id\" from \"folders\" as \"t\" where \"t\".\"owner_id\" = $2))","params":["alice","alice"],"result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Bitmap Heap Scan\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"folders\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 17.88,\n \"Total Cost\": 27.36,\n \"Plan Rows\": 3,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Recheck Cond\": \"(t.owner_id = 'alice'::text)\",\n \"Filter\": \"((t.parent_id IS NULL) OR (ANY (t.parent_id = (hashed SubPlan 1).col1)))\",\n \"Plans\": [\n {\n \"Node Type\": \"Bitmap Index Scan\",\n \"Parent Relationship\": \"Outer\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Index Name\": \"folders_owner_id_idx\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 4.20,\n \"Plan Rows\": 6,\n \"Plan Width\": 0,\n \"Disabled\": false,\n \"Index Cond\": \"(t.owner_id = 'alice'::text)\"\n },\n {\n \"Node Type\": \"Bitmap Heap Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 1\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"folders\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 4.20,\n \"Total Cost\": 13.67,\n \"Plan Rows\": 6,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\"],\n \"Recheck Cond\": \"(t_1.owner_id = 'alice'::text)\",\n \"Plans\": [\n {\n \"Node Type\": \"Bitmap Index Scan\",\n \"Parent Relationship\": \"Outer\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Index Name\": \"folders_owner_id_idx\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 4.20,\n \"Plan Rows\": 6,\n \"Plan Width\": 0,\n \"Disabled\": false,\n \"Index Cond\": \"(t_1.owner_id = 'alice'::text)\"\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 \"id\" as \"id\", \"parent_id\" as \"parent_id\" from \"folders\" as t where (\"id\") in (($1), ($2))","params":["1","2"],"result":{"command":"SELECT","rowCount":2,"columns":[["id",23],["parent_id",23]],"rows":[ ["1",null], ["2","1"] ]}}, {"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\", \"owner_id\" as \"owner_id\", \"parent_id\" as \"parent_id\" from \"folders\" as t where \"id\" = $1 and \"t\".\"owner_id\" = $2 and (\"t\".\"parent_id\" is null or \"t\".\"parent_id\" in (select \"t\".\"id\" from \"folders\" as \"t\" where \"t\".\"owner_id\" = $3)) limit 1","params":["1","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["owner_id",25],["parent_id",23]],"rows":[["1","alice",null]]}}, {"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\".\"owner_id\" as \"owner_id\", \"t\".\"parent_id\" as \"parent_id\", \"t\".\"id\"::text as \"__pb_key0\" from \"folders\" as \"t\" where \"t\".\"owner_id\" = $1 and (\"t\".\"parent_id\" is null or \"t\".\"parent_id\" in (select \"t\".\"id\" from \"folders\" as \"t\" where \"t\".\"owner_id\" = $2)) order by \"t\".\"id\" asc limit $3","params":["bob","bob","51"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["owner_id",25],["parent_id",23],["__pb_key0",25]],"rows":[["3","bob",null,"3"]]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"folders\" as \"t\" where \"t\".\"owner_id\" = $1 and (\"t\".\"parent_id\" is null or \"t\".\"parent_id\" in (select \"t\".\"id\" from \"folders\" as \"t\" where \"t\".\"owner_id\" = $2))","params":["bob","bob"],"result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Bitmap Heap Scan\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"folders\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 17.88,\n \"Total Cost\": 27.36,\n \"Plan Rows\": 3,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Recheck Cond\": \"(t.owner_id = 'bob'::text)\",\n \"Filter\": \"((t.parent_id IS NULL) OR (ANY (t.parent_id = (hashed SubPlan 1).col1)))\",\n \"Plans\": [\n {\n \"Node Type\": \"Bitmap Index Scan\",\n \"Parent Relationship\": \"Outer\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Index Name\": \"folders_owner_id_idx\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 4.20,\n \"Plan Rows\": 6,\n \"Plan Width\": 0,\n \"Disabled\": false,\n \"Index Cond\": \"(t.owner_id = 'bob'::text)\"\n },\n {\n \"Node Type\": \"Bitmap Heap Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 1\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"folders\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 4.20,\n \"Total Cost\": 13.67,\n \"Plan Rows\": 6,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\"],\n \"Recheck Cond\": \"(t_1.owner_id = 'bob'::text)\",\n \"Plans\": [\n {\n \"Node Type\": \"Bitmap Index Scan\",\n \"Parent Relationship\": \"Outer\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Index Name\": \"folders_owner_id_idx\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 4.20,\n \"Plan Rows\": 6,\n \"Plan Width\": 0,\n \"Disabled\": false,\n \"Index Cond\": \"(t_1.owner_id = 'bob'::text)\"\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 \"id\" as \"id\", \"parent_id\" as \"parent_id\" from \"folders\" as t where (\"id\") in (($1))","params":["3"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["parent_id",23]],"rows":[["3",null]]}}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a child under .parent(fk, \"read\") > keeps a reply linked only to its thread to the thread's channel": { "(hooks)#0": [ {"sql":"select relkind from pg_class where oid = to_regclass($1)","params":["\"replies\""],"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":["\"replies\""],"result":{"command":"SELECT","rowCount":6,"columns":[["name",19],["method",19],["partial",16],["column",25],["definition",25],["opclass",25]],"rows":[ ["replies_body_idx","btree","f","body","body","text_ops"], ["replies_body_idx1","gin","f","body","body","gin_trgm_ops"], ["replies_channel_id_idx","btree","f","channel_id","channel_id","int4_ops"], ["replies_id_idx","btree","f","id","id","int4_ops"], ["replies_pkey","btree","f","id","id","int4_ops"], ["replies_thread_id_idx","btree","f","thread_id","thread_id","int4_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\".\"tenant_id\" as \"tenant_id\", \"t\".\"channel_id\" as \"channel_id\", \"t\".\"thread_id\" as \"thread_id\", \"t\".\"body\" as \"body\", \"t\".\"id\"::text as \"__pb_key0\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $7 and (\"t\".\"kind\" = $8 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $9) or \"t\".\"member_ids\"::jsonb @> to_jsonb($10::text))))) order by \"t\".\"id\" asc limit $11","params":["1","1","1","public","bob","bob","1","public","bob","bob","51"],"result":{"command":"SELECT","rowCount":0,"columns":[["id",23],["tenant_id",23],["channel_id",23],["thread_id",23],["body",25],["__pb_key0",25]],"rows":[]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $7 and (\"t\".\"kind\" = $8 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $9) or \"t\".\"member_ids\"::jsonb @> to_jsonb($10::text)))))","params":["1","1","1","public","bob","bob","1","public","bob","bob"],"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\": \"replies\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 79.81,\n \"Total Cost\": 108.54,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Filter\": \"(((t.thread_id IS NULL) OR (ANY (t.thread_id = (hashed SubPlan 2).col1))) AND ((t.channel_id IS NULL) OR (ANY (t.channel_id = (hashed SubPlan 3).col1))) AND (t.tenant_id = 1))\",\n \"Plans\": [\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 2\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"replies\",\n \"Schema\": \"public\",\n \"Alias\": \"t_2\",\n \"Startup Cost\": 26.88,\n \"Total Cost\": 52.93,\n \"Plan Rows\": 3,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_2.id\"],\n \"Filter\": \"(((t_2.channel_id IS NULL) OR (ANY (t_2.channel_id = (hashed SubPlan 1).col1))) AND (t_2.tenant_id = 1))\",\n \"Plans\": [\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 1\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"channels\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 26.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\"],\n \"Filter\": \"((t_1.deleted_at IS NULL) AND (t_1.tenant_id = 1) AND ((t_1.kind = 'public'::text) OR jsonb_exists(t_1.member_ids, 'bob'::text) OR (t_1.member_ids @> to_jsonb('bob'::text))))\"\n }\n ]\n },\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 3\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"channels\",\n \"Schema\": \"public\",\n \"Alias\": \"t_3\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 26.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_3.id\"],\n \"Filter\": \"((t_3.deleted_at IS NULL) AND (t_3.tenant_id = 1) AND ((t_3.kind = 'public'::text) OR jsonb_exists(t_3.member_ids, 'bob'::text) OR (t_3.member_ids @> to_jsonb('bob'::text))))\"\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\".\"channel_id\" as \"channel_id\", \"t\".\"thread_id\" as \"thread_id\", \"t\".\"body\" as \"body\", \"t\".\"id\"::text as \"__pb_key0\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $7 and (\"t\".\"kind\" = $8 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $9) or \"t\".\"member_ids\"::jsonb @> to_jsonb($10::text))))) and (((\"t\".\"body\"::text is not null and \"t\".\"body\"::text ilike $11))) order by \"t\".\"id\" asc limit $12","params":["1","1","1","public","bob","bob","1","public","bob","bob","%reply%","51"],"result":{"command":"SELECT","rowCount":0,"columns":[["id",23],["tenant_id",23],["channel_id",23],["thread_id",23],["body",25],["__pb_key0",25]],"rows":[]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $7 and (\"t\".\"kind\" = $8 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $9) or \"t\".\"member_ids\"::jsonb @> to_jsonb($10::text))))) and (((\"t\".\"body\"::text is not null and \"t\".\"body\"::text ilike $11)))","params":["1","1","1","public","bob","bob","1","public","bob","bob","%reply%"],"result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Bitmap Heap Scan\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"replies\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 101.48,\n \"Total Cost\": 106.84,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Recheck Cond\": \"(t.body ~~* '%reply%'::text)\",\n \"Filter\": \"(((t.thread_id IS NULL) OR (ANY (t.thread_id = (hashed SubPlan 2).col1))) AND ((t.channel_id IS NULL) OR (ANY (t.channel_id = (hashed SubPlan 3).col1))) AND (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\": \"replies_body_idx1\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 21.67,\n \"Plan Rows\": 2,\n \"Plan Width\": 0,\n \"Disabled\": false,\n \"Index Cond\": \"(t.body ~~* '%reply%'::text)\"\n },\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 2\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"replies\",\n \"Schema\": \"public\",\n \"Alias\": \"t_2\",\n \"Startup Cost\": 26.88,\n \"Total Cost\": 52.93,\n \"Plan Rows\": 3,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_2.id\"],\n \"Filter\": \"(((t_2.channel_id IS NULL) OR (ANY (t_2.channel_id = (hashed SubPlan 1).col1))) AND (t_2.tenant_id = 1))\",\n \"Plans\": [\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 1\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"channels\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 26.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\"],\n \"Filter\": \"((t_1.deleted_at IS NULL) AND (t_1.tenant_id = 1) AND ((t_1.kind = 'public'::text) OR jsonb_exists(t_1.member_ids, 'bob'::text) OR (t_1.member_ids @> to_jsonb('bob'::text))))\"\n }\n ]\n },\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 3\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"channels\",\n \"Schema\": \"public\",\n \"Alias\": \"t_3\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 26.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_3.id\"],\n \"Filter\": \"((t_3.deleted_at IS NULL) AND (t_3.tenant_id = 1) AND ((t_3.kind = 'public'::text) OR jsonb_exists(t_3.member_ids, 'bob'::text) OR (t_3.member_ids @> to_jsonb('bob'::text))))\"\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\".\"thread_id\" as \"value\", count(*)::text as \"n\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $7 and (\"t\".\"kind\" = $8 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $9) or \"t\".\"member_ids\"::jsonb @> to_jsonb($10::text))))) group by \"t\".\"thread_id\" order by count(*) desc, \"t\".\"thread_id\" asc limit $11","params":["1","1","1","public","bob","bob","1","public","bob","bob","100"],"result":{"command":"SELECT","rowCount":0,"columns":[["value",23],["n",25]],"rows":[]}}, {"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\", \"channel_id\" as \"channel_id\", \"thread_id\" as \"thread_id\", \"body\" as \"body\" from \"replies\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $3 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $4 and (\"t\".\"kind\" = $5 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $6) or \"t\".\"member_ids\"::jsonb @> to_jsonb($7::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $8 and (\"t\".\"kind\" = $9 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $10) or \"t\".\"member_ids\"::jsonb @> to_jsonb($11::text))))) limit 1","params":["1","2","1","1","public","bob","bob","1","public","bob","bob"],"result":{"command":"SELECT","rowCount":0,"columns":[["id",23],["tenant_id",23],["channel_id",23],["thread_id",23],["body",25]],"rows":[]}}, {"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\".\"channel_id\" as \"channel_id\", \"t\".\"thread_id\" as \"thread_id\", \"t\".\"body\" as \"body\", \"t\".\"id\"::text as \"__pb_key0\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $7 and (\"t\".\"kind\" = $8 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $9) or \"t\".\"member_ids\"::jsonb @> to_jsonb($10::text))))) order by \"t\".\"id\" asc limit $11","params":["1","1","1","public","alice","alice","1","public","alice","alice","51"],"result":{"command":"SELECT","rowCount":2,"columns":[["id",23],["tenant_id",23],["channel_id",23],["thread_id",23],["body",25],["__pb_key0",25]],"rows":[ ["1","1","2",null,"private thread","1"], ["2","1",null,"1","private reply","2"] ]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $7 and (\"t\".\"kind\" = $8 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $9) or \"t\".\"member_ids\"::jsonb @> to_jsonb($10::text)))))","params":["1","1","1","public","alice","alice","1","public","alice","alice"],"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\": \"replies\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 79.81,\n \"Total Cost\": 108.54,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Filter\": \"(((t.thread_id IS NULL) OR (ANY (t.thread_id = (hashed SubPlan 2).col1))) AND ((t.channel_id IS NULL) OR (ANY (t.channel_id = (hashed SubPlan 3).col1))) AND (t.tenant_id = 1))\",\n \"Plans\": [\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 2\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"replies\",\n \"Schema\": \"public\",\n \"Alias\": \"t_2\",\n \"Startup Cost\": 26.88,\n \"Total Cost\": 52.93,\n \"Plan Rows\": 3,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_2.id\"],\n \"Filter\": \"(((t_2.channel_id IS NULL) OR (ANY (t_2.channel_id = (hashed SubPlan 1).col1))) AND (t_2.tenant_id = 1))\",\n \"Plans\": [\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 1\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"channels\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 26.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\"],\n \"Filter\": \"((t_1.deleted_at IS NULL) AND (t_1.tenant_id = 1) AND ((t_1.kind = 'public'::text) OR jsonb_exists(t_1.member_ids, 'alice'::text) OR (t_1.member_ids @> to_jsonb('alice'::text))))\"\n }\n ]\n },\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 3\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"channels\",\n \"Schema\": \"public\",\n \"Alias\": \"t_3\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 26.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_3.id\"],\n \"Filter\": \"((t_3.deleted_at IS NULL) AND (t_3.tenant_id = 1) AND ((t_3.kind = 'public'::text) OR jsonb_exists(t_3.member_ids, 'alice'::text) OR (t_3.member_ids @> to_jsonb('alice'::text))))\"\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 \"id\" as \"id\", \"thread_id\" as \"thread_id\", \"channel_id\" as \"channel_id\" from \"replies\" as t where \"tenant_id\" = $1 and (\"id\") in (($2), ($3))","params":["1","1","2"],"result":{"command":"SELECT","rowCount":2,"columns":[["id",23],["thread_id",23],["channel_id",23]],"rows":[ ["1",null,"2"], ["2","1",null] ]}}, {"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\", \"kind\" as \"kind\", \"member_ids\" as \"member_ids\", \"deleted_at\" as \"deleted_at\" from \"channels\" as t where \"deleted_at\" is null and \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"kind\" = $3 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $4) or \"t\".\"member_ids\"::jsonb @> to_jsonb($5::text))) limit 1","params":["1","2","public","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["kind",25],["member_ids",3802],["deleted_at",1184]],"rows":[["2","1","private","[\"alice\"]",null]]}}, {"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"]]}}, {"repeated":4}, {"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\".\"channel_id\" as \"channel_id\", \"t\".\"thread_id\" as \"thread_id\", \"t\".\"body\" as \"body\", \"t\".\"id\"::text as \"__pb_key0\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $7 and (\"t\".\"kind\" = $8 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $9) or \"t\".\"member_ids\"::jsonb @> to_jsonb($10::text))))) and (((\"t\".\"body\"::text is not null and \"t\".\"body\"::text ilike $11))) order by \"t\".\"id\" asc limit $12","params":["1","1","1","public","alice","alice","1","public","alice","alice","%reply%","51"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["channel_id",23],["thread_id",23],["body",25],["__pb_key0",25]],"rows":[["2","1",null,"1","private reply","2"]]}}, {"sql":"EXPLAIN (VERBOSE, FORMAT JSON) select 1 as \"one\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $7 and (\"t\".\"kind\" = $8 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $9) or \"t\".\"member_ids\"::jsonb @> to_jsonb($10::text))))) and (((\"t\".\"body\"::text is not null and \"t\".\"body\"::text ilike $11)))","params":["1","1","1","public","alice","alice","1","public","alice","alice","%reply%"],"result":{"command":"EXPLAIN","rowCount":null,"columns":[["QUERY PLAN",114]],"rows":[["[\n {\n \"Plan\": {\n \"Node Type\": \"Bitmap Heap Scan\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"replies\",\n \"Schema\": \"public\",\n \"Alias\": \"t\",\n \"Startup Cost\": 101.48,\n \"Total Cost\": 106.84,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"1\"],\n \"Recheck Cond\": \"(t.body ~~* '%reply%'::text)\",\n \"Filter\": \"(((t.thread_id IS NULL) OR (ANY (t.thread_id = (hashed SubPlan 2).col1))) AND ((t.channel_id IS NULL) OR (ANY (t.channel_id = (hashed SubPlan 3).col1))) AND (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\": \"replies_body_idx1\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 21.67,\n \"Plan Rows\": 2,\n \"Plan Width\": 0,\n \"Disabled\": false,\n \"Index Cond\": \"(t.body ~~* '%reply%'::text)\"\n },\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 2\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"replies\",\n \"Schema\": \"public\",\n \"Alias\": \"t_2\",\n \"Startup Cost\": 26.88,\n \"Total Cost\": 52.93,\n \"Plan Rows\": 3,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_2.id\"],\n \"Filter\": \"(((t_2.channel_id IS NULL) OR (ANY (t_2.channel_id = (hashed SubPlan 1).col1))) AND (t_2.tenant_id = 1))\",\n \"Plans\": [\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 1\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"channels\",\n \"Schema\": \"public\",\n \"Alias\": \"t_1\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 26.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_1.id\"],\n \"Filter\": \"((t_1.deleted_at IS NULL) AND (t_1.tenant_id = 1) AND ((t_1.kind = 'public'::text) OR jsonb_exists(t_1.member_ids, 'alice'::text) OR (t_1.member_ids @> to_jsonb('alice'::text))))\"\n }\n ]\n },\n {\n \"Node Type\": \"Seq Scan\",\n \"Parent Relationship\": \"SubPlan\",\n \"Subplan Name\": \"SubPlan 3\",\n \"Parallel Aware\": false,\n \"Async Capable\": false,\n \"Relation Name\": \"channels\",\n \"Schema\": \"public\",\n \"Alias\": \"t_3\",\n \"Startup Cost\": 0.00,\n \"Total Cost\": 26.88,\n \"Plan Rows\": 1,\n \"Plan Width\": 4,\n \"Disabled\": false,\n \"Output\": [\"t_3.id\"],\n \"Filter\": \"((t_3.deleted_at IS NULL) AND (t_3.tenant_id = 1) AND ((t_3.kind = 'public'::text) OR jsonb_exists(t_3.member_ids, 'alice'::text) OR (t_3.member_ids @> to_jsonb('alice'::text))))\"\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 \"id\" as \"id\", \"thread_id\" as \"thread_id\", \"channel_id\" as \"channel_id\" from \"replies\" as t where \"tenant_id\" = $1 and (\"id\") in (($2))","params":["1","2"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["thread_id",23],["channel_id",23]],"rows":[["2","1",null]]}}, {"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"]]}}, {"repeated":4}, {"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\".\"thread_id\" as \"value\", count(*)::text as \"n\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $1 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $2 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $3 and (\"t\".\"kind\" = $4 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $5) or \"t\".\"member_ids\"::jsonb @> to_jsonb($6::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $7 and (\"t\".\"kind\" = $8 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $9) or \"t\".\"member_ids\"::jsonb @> to_jsonb($10::text))))) group by \"t\".\"thread_id\" order by count(*) desc, \"t\".\"thread_id\" asc limit $11","params":["1","1","1","public","alice","alice","1","public","alice","alice","100"],"result":{"command":"SELECT","rowCount":2,"columns":[["value",23],["n",25]],"rows":[ ["1","1"], [null,"1"] ]}}, {"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\", \"channel_id\" as \"channel_id\", \"thread_id\" as \"thread_id\", \"body\" as \"body\" from \"replies\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $3 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $4 and (\"t\".\"kind\" = $5 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $6) or \"t\".\"member_ids\"::jsonb @> to_jsonb($7::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $8 and (\"t\".\"kind\" = $9 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $10) or \"t\".\"member_ids\"::jsonb @> to_jsonb($11::text))))) limit 1","params":["1","2","1","1","public","alice","alice","1","public","alice","alice"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["tenant_id",23],["channel_id",23],["thread_id",23],["body",25]],"rows":[["2","1",null,"1","private reply"]]}}, {"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\", \"thread_id\" as \"thread_id\", \"channel_id\" as \"channel_id\" from \"replies\" as t where \"tenant_id\" = $1 and (\"id\") in (($2))","params":["1","2"],"result":{"command":"SELECT","rowCount":1,"columns":[["id",23],["thread_id",23],["channel_id",23]],"rows":[["2","1",null]]}}, {"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"]]}}, {"repeated":4}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] }, "a child under .parent(fk, \"read\") > refuses a reply under a thread whose channel the caller does not read": { "(hooks)#0": [ {"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\":\"bob\",\"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\", \"channel_id\" as \"channel_id\", \"thread_id\" as \"thread_id\", \"body\" as \"body\" from \"replies\" as t where \"tenant_id\" = $1 and \"id\" = $2 and (\"t\".\"thread_id\" is null or \"t\".\"thread_id\" in (select \"t\".\"id\" from \"replies\" as \"t\" where \"t\".\"tenant_id\" = $3 and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $4 and (\"t\".\"kind\" = $5 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $6) or \"t\".\"member_ids\"::jsonb @> to_jsonb($7::text))))))) and (\"t\".\"channel_id\" is null or \"t\".\"channel_id\" in (select \"t\".\"id\" from \"channels\" as \"t\" where \"t\".\"deleted_at\" is null and \"t\".\"tenant_id\" = $8 and (\"t\".\"kind\" = $9 or (jsonb_exists(\"t\".\"member_ids\"::jsonb, $10) or \"t\".\"member_ids\"::jsonb @> to_jsonb($11::text))))) limit 1 for no key update","params":["1","1","1","1","public","bob","bob","1","public","bob","bob"],"result":{"command":"SELECT","rowCount":0,"columns":[["id",23],["tenant_id",23],["channel_id",23],["thread_id",23],["body",25]],"rows":[]}}, {"sql":"rollback","result":{"command":"ROLLBACK","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\":\"alice\",\"roles\":[\"member\"]}"],"result":{"command":"SELECT","rowCount":1,"columns":[["set_config",25],["?column?",16]],"rows":[["1s","t"]]}}, {"repeated":5}, {"sql":"insert into \"replies\" (\"id\", \"thread_id\", \"body\", \"tenant_id\") values ($1, $2, $3, $4) returning \"id\" as \"id\", \"tenant_id\" as \"tenant_id\", \"channel_id\" as \"channel_id\", \"thread_id\" as \"thread_id\", \"body\" as \"body\"","params":["3","1","me too","1"],"result":{"command":"INSERT","rowCount":1,"columns":[["id",23],["tenant_id",23],["channel_id",23],["thread_id",23],["body",25]],"rows":[["3","1",null,"1","me too"]]}}, {"repeated":5}, {"sql":"commit","result":{"command":"COMMIT","rowCount":null,"columns":[],"rows":[]}} ] } }