jOOQ / jOOQ

jOOQ is the best way to write SQL in Java
https://www.jooq.org
Other
6.08k stars 1.2k forks source link

Add support for DEFERRABLE constraints #10363

Open lukaseder opened 4 years ago

lukaseder commented 4 years ago

A few RDBMS support DEFERRABLE constraints, which we currently don't support in our DDL statement feature set. A DEFERRABLE constraint is a constraint that is enforced only at the end of a transaction.

Such RDBMS include (list will be enhanced after further research):


See also: https://github.com/jOOQ/jOOQ/issues/11211

nielsmeijer commented 1 year ago

While researching how to create deferrable foreign keys in PostgreSQL/Oracle using jOOQ i came across this ticket and https://github.com/jOOQ/jOOQ/issues/8799.

Good to see this improvement on the roadmap/TODO list.

Is there a work-around available to create foreign keys with the deferrable keyword in the mean time?

lukaseder commented 1 year ago

and #8799.

Thanks for pointing out the duplicate.

Is there a work-around available to create foreign keys with the deferrable keyword in the mean time?

Use plain SQL for your entire DDL query or use an ExecuteListener to patch the generated SQL. There aren't any plain SQL templates for DDL fragments yet, as this isn't too popular.

lukaseder commented 1 year ago

As a workaround, maybe it's simpler to just offer plain SQL TableElement and CustomTableElement types where users can implement their own syntax for inclusion in CREATE TABLE and ALTER TABLE statements. https://github.com/jOOQ/jOOQ/issues/14807