Hi Hayden,
Thank you very much for your message. I'm assuming you mean that you compared two columns in a JOIN .. ON clause that were not meant to be compared, because they were unrelated. There are a number of tools in jOOQ already, that would prevent this for some cases. For example:
- You could use onKey(), which works in simple join graphs, where it automatically finds the right columns that need to be used when joining between two tables. It breaks as soon as the join graph yields ambiguities, i.e. as soon as there are several possible ways to join two tables (note that by "table", I mean join sub-graph)
We could definitely implement an introspection that would allow for logging a warning / throwing an exception, if a join is not an equi join. Of course, this introspection would not be turned on by default, because a join is not necessarily an equi join. It is just an ordinary relational operator, based on the cross product operation. Also, a lot of people do not use foreign key constraints at all, or at least not everywhere in their schema. But it's a useful introspection nonetheless, just like the one where we check if update / delete statements have a where clause.
I have created a feature request for this:
You could implement your own validation using a VisitListener (which you could turn off in production, for performance reasons). It is not trivial, but definitely possible.
Thanks,
Lukas