Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow excluding constraints, including specific kinds, from generator #7608

Closed
Diagoras opened this issue Jun 21, 2018 · 2 comments
Closed

Comments

@Diagoras
Copy link
Contributor

When using the XmlGenerator, constraints of types PRIMARY KEY, FOREIGN KEY, UNIQUE, and CHECK are all generated under the "table_constraints" section. This results in a lot of clashes in Git for my team since Postgres randomly generates the name of NOT NULL constraints (unless you explicitly specify them).

It'd be nice if there was not only a flag to disable generating these constraints, but also a way to switch off specific kinds (ie. the four given above).

Versions:

  • jOOQ: 3.11.0
  • Java: 1.8
  • Database (include vendor): Postgres 9.3
  • OS: MacOS
  • JDBC Driver (include name if inofficial driver): 42.2.2
@lukaseder
Copy link
Member

Thanks for the suggestion.

Egh. All constraint types can be turned off, except for check constraints:
https://www.jooq.org/doc/3.11/manual/code-generation/codegen-advanced/codegen-config-database/codegen-database-include-object-types

It should definitely be possible to exclude those object types. Also, the <includes/> / <excludes/> mechanism could be extended to also match constraint names.

Note that while NOT NULL constraints are reported as check constraints, in many databases (including PostgreSQL: https://dba.stackexchange.com/q/158499/2512), they're optimised check constraints, so I wouldn't name them explicitly just to work around this flaw.

As a workaround, you can, of course, extend the PostgresDatabase from jOOQ-meta and override the loadCheckConstraints() method either filtering the result, or returning an empty result:
https://github.com/jOOQ/jOOQ/blob/version-3.11.1/jOOQ-meta/src/main/java/org/jooq/meta/postgres/PostgresDatabase.java#L317

@lukaseder
Copy link
Member

By now, in jOOQ 3.14, I think that all the required features here are available or addressed in separate issues:

Closing this as a duplicate of the above two issues.

3.14 Other improvements automation moved this from To do to Done Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

2 participants