feat: expose composite foreign keys and m2m columns in OpenAPI
Replace the single-column `<fk table='...' column='...'/>` marker with a unified, composite-capable format `<fk table='...' columns='local:foreign,...'/>` and emit full column lists for many-to-many markers, so clients can reconstruct composite relationships. - Match every real table relationship a column participates in, instead of only single-column foreign keys, still preferring tables over the view-derived relationships. - Emit the full ordered local->foreign column mapping in the `<fk>` marker and the full source/target column lists in the `<m2m>` marker. - Add composite foreign key and composite m2m fixtures plus OpenAPI spec assertions.
This commit is contained in:
Vendored
+52
@@ -1246,6 +1246,58 @@ create table test.being_part (
|
||||
primary key(being, part)
|
||||
);
|
||||
|
||||
-- Tables for testing composite foreign keys in the OpenAPI output
|
||||
create table test.comp_product (
|
||||
id int primary key,
|
||||
name text
|
||||
);
|
||||
|
||||
create table test.comp_component (
|
||||
product_id int not null references test.comp_product(id),
|
||||
component_id int not null references test.comp_product(id),
|
||||
primary key(product_id, component_id)
|
||||
);
|
||||
|
||||
create table test.comp_product_instance (
|
||||
id int primary key,
|
||||
product_id int not null references test.comp_product(id),
|
||||
unique(id, product_id)
|
||||
);
|
||||
|
||||
create table test.comp_component_instance (
|
||||
product_instance_id int not null,
|
||||
product_id int not null,
|
||||
component_instance_id int not null,
|
||||
component_id int not null,
|
||||
primary key(product_instance_id, component_id),
|
||||
constraint comp_component_instance_parent_fkey foreign key (product_instance_id, product_id) references test.comp_product_instance(id, product_id),
|
||||
constraint comp_component_instance_child_fkey foreign key (component_instance_id, component_id) references test.comp_product_instance(id, product_id),
|
||||
constraint comp_component_instance_component_fkey foreign key (product_id, component_id) references test.comp_component(product_id, component_id)
|
||||
);
|
||||
|
||||
-- Tables for testing composite m2m relationships in the OpenAPI output
|
||||
create table test.comp_being (
|
||||
a int not null,
|
||||
b int not null,
|
||||
primary key(a, b)
|
||||
);
|
||||
|
||||
create table test.comp_thing (
|
||||
x int not null,
|
||||
y int not null,
|
||||
primary key(x, y)
|
||||
);
|
||||
|
||||
create table test.comp_being_thing (
|
||||
a int not null,
|
||||
b int not null,
|
||||
x int not null,
|
||||
y int not null,
|
||||
primary key(a, b, x, y),
|
||||
constraint comp_being_thing_being_fkey foreign key (a, b) references test.comp_being(a, b),
|
||||
constraint comp_being_thing_thing_fkey foreign key (x, y) references test.comp_thing(x, y)
|
||||
);
|
||||
|
||||
create function test.single_out_param(num int, OUT num_plus_one int) AS $$
|
||||
select num + 1;
|
||||
$$ language sql;
|
||||
|
||||
Reference in New Issue
Block a user