Hi
While trying to setup partitioned tables, I have noticed that the code generator seem to have a bug or feature where it does not alway generate all the foreign keys.
When running the code generator on the following H2 database:
create table parent (
id int generated by default as identity,
partition_id tinyint not null,
constraint pk_parent primary key (id, partition_id)
);
create table child1 (
id int generated by default as identity,
parent_id int not null,
partition_id tinyint not null,
constraint pk_child1 primary key (id),
constraint fk_child1_parent foreign key (parent_id, partition_id) references parent (id, partition_id)
);
create table child2 (
id int generated by default as identity,
parent_id int not null,
constraint pk_child2 primary key (id),
-- this fk does not cover the parents pk
constraint fk_child2_parent foreign key (parent_id) references parent (id)
);
The foreign key for child2 is not generated (note that this fk is a bit funky, since it only references part of the parent pk).
The only generator log output regarding foreign keys is this:
[INFO] Adding foreign key : FK_CHILD1_PARENT (PUBLIC.CHILD1.PARENT_ID) referencing PK_PARENT (
PUBLIC.PARENT.ID)
[INFO] Adding foreign key : FK_CHILD1_PARENT (PUBLIC.CHILD1.PARTITION_ID) referencing PK_PARENT (PUBLIC.PARENT.PARTITION_ID)
I can push an example to github or supply generator log. I tested with jooq v1.15.2 and initially discovered it on v3.14.13.
Best regards Jens