feat: filter top-level resource with embed filter
This is enabled by adding `!inner` to the embedded resource /projects?select=*,clients!inner(*)&clients.id=eq.12 This behaviour can be enabled by default with the config option db-embed-default-join='inner' Which saves the need for specifying `!inner` on every request. If this is enabled, the previous behavior can be restored per request by specifying `!left` on the embedded resource. /projects?select=*,clients!left(*)&clients.id=eq.12` Tested on M20/02M/M2M relationships, views, RPC.
This commit is contained in:
committed by
Steve Chavez
parent
bf91187e63
commit
ee56dd5db1
Vendored
+16
-1
@@ -691,4 +691,19 @@ DO $do$BEGIN
|
||||
INSERT INTO test.reference_to_partitioned(id) VALUES (1);
|
||||
INSERT INTO test.reference_to_partitioned(id, id_a, name_a) VALUES (2, 2, 'first');
|
||||
END IF;
|
||||
END$do$;
|
||||
END$do$;
|
||||
|
||||
TRUNCATE TABLE test.products CASCADE;
|
||||
INSERT INTO test.products (id, name) VALUES (1,'product-1'), (2,'product-2'), (3,'product-3');
|
||||
|
||||
TRUNCATE TABLE test.suppliers CASCADE;
|
||||
INSERT INTO test.suppliers (id, name) VALUES (1,'supplier-1'), (2,'supplier-2'), (3, 'supplier-3');
|
||||
|
||||
TRUNCATE TABLE test.products_suppliers CASCADE;
|
||||
INSERT INTO test.products_suppliers (product_id, supplier_id) VALUES (1,1), (1,2), (2,1), (2,3);
|
||||
|
||||
TRUNCATE TABLE test.trade_unions CASCADE;
|
||||
INSERT INTO test.trade_unions (id, name) VALUES (1,'union-1'), (2,'union-2'), (3, 'union-3'), (4, 'union-4');
|
||||
|
||||
TRUNCATE TABLE test.suppliers_trade_unions CASCADE;
|
||||
INSERT INTO test.suppliers_trade_unions (supplier_id, trade_union_id) VALUES (1,1), (1,2), (2,3), (2,4);
|
||||
Vendored
+5
@@ -151,6 +151,11 @@ GRANT ALL ON TABLE
|
||||
, schauspieler
|
||||
, filme
|
||||
, rollen
|
||||
, products
|
||||
, suppliers
|
||||
, products_suppliers
|
||||
, trade_unions
|
||||
, suppliers_trade_unions
|
||||
TO postgrest_test_anonymous;
|
||||
|
||||
GRANT INSERT ON TABLE insertonly TO postgrest_test_anonymous;
|
||||
|
||||
Vendored
+27
@@ -2284,3 +2284,30 @@ $$ language sql;
|
||||
create or replace function test.overloaded_unnamed_param(x int, y int) returns int as $$
|
||||
select x + y;
|
||||
$$ language sql;
|
||||
|
||||
create table products(
|
||||
id int primary key
|
||||
, name text
|
||||
);
|
||||
|
||||
create table suppliers(
|
||||
id int primary key
|
||||
, name text
|
||||
);
|
||||
|
||||
create table products_suppliers(
|
||||
product_id int references products(id),
|
||||
supplier_id int references suppliers(id),
|
||||
primary key (product_id, supplier_id)
|
||||
);
|
||||
|
||||
create table trade_unions(
|
||||
id int primary key
|
||||
, name text
|
||||
);
|
||||
|
||||
create table suppliers_trade_unions(
|
||||
supplier_id int references suppliers(id),
|
||||
trade_union_id int references trade_unions(id),
|
||||
primary key (supplier_id, trade_union_id)
|
||||
);
|
||||
Reference in New Issue
Block a user