jOOQ icon indicating copy to clipboard operation
jOOQ copied to clipboard

Add deprecation warnings on path expressions/foreign keys that include deprecated columns

Open alf opened this issue 1 year ago • 1 comments

Use case

We have some deprecated columns in our database. Some of these columns are not used directly, they are only used for joining (using onKey or path joins).

It would be nice if we could have compiler warnings when this occurs, however I can't find a good way to affect this.

Possible solution

jOOQ knows which columns are being used by path joins and could mark the path join methods as deprecated.

Possible workarounds

Haven't found any other than plugging into the code generator.

jOOQ Version

3.19.1

Database product and version

Oracle 18 XE

Java Version

No response

OS Version

No response

JDBC driver name and version (include name if unofficial driver)

No response

alf avatar Jan 11 '24 12:01 alf

It would be nice if we could have compiler warnings when this occurs, however I can't find a good way to affect this.

You can deprecate your columns with comments, including:

  • Actual SQL comments containing @deprecated
  • Synthetic comments: https://www.jooq.org/doc/latest/manual/code-generation/codegen-advanced/codegen-config-database/codegen-database-comments/

There's no automatic way to assign these comments to all keys, but you can use programmatic code generation to generate the regular expression for the flag dynamically.

You could even hide the columns by making them package private:

  • https://www.jooq.org/doc/latest/manual/code-generation/codegen-advanced/codegen-config-database/codegen-database-forced-types/codegen-database-forced-types-visibility/

They'll still be available to the paths, but not to user code.

jOOQ knows which columns are being used by path joins and could mark the path join methods as deprecated.

I'm not convinced that this is a common enough case for a feature. Path joins only ever take you so far. Some joins over more than 2 tables cannot be expressed as paths. But you never know. Perhaps this will turn out to be a good idea in the future after all, so I'm keeping this open for now, on the long term roadmap.

lukaseder avatar Jan 11 '24 13:01 lukaseder