Hello,

Thank you for your message.

2015-11-30 21:19 GMT+01:00 <[email protected]>:

> Hello,
>
> I just stumbled upon the enhancement issue "#4724 Add Table.eq(Table<R>)
> and Table.ne(Table<R>)" [1]. I have trouble understanding when a self-join
> using the primary key (or all columns) would be useful. None of the
> self-joins I ever wrote were of the form ON t1.id = t2.id. Rather, I
> usually join ON t1.parent_id = t2.id or similar. Since the data from t1
> and t2 will be duplicated, there is nothing new to filter or select. So
> what legitimate use cases are there for such a convenience method?
>

Indeed, the equi-join seems a bit weird. It makes more sense when looking
at the non-equi-join comparison. The main idea behind this is the fact that
a table expression is not too different from a row value expression. For
instance, in PostgreSQL, it is perfectly fine to write:

select a1, count(*)
from actor a1
join actor a2 on a1 != a2
and (a1.first_name, a1.last_name) > (a2.first_name, a2.last_name)
group by a1


The really interesting change here is
https://github.com/jOOQ/jOOQ/issues/4727, where we will start treating rows
and columns as the same thing (as it should be in all SQL implementations).

So, I think it is fair to say that this is not really a convenience method,
but an actual SQL feature.


> I realize the above discussion may not seem JOOQ specific, so let me add
> the following: I recently ran into unexpected behavior (to me) due to a
> subtle confusion of the `equal()` and `equals()` methods as documented in
> "#4366 Add on(Boolean), where(Boolean), having(Boolean), etc.". Therefore,
> if the Table.equal(Table<R>) feature will be included in 3.8, I'd at least
> like to understand the intended feature before I can accidentally trigger
> it ;-)
>

I admit that the equal() vs equals() issue that you've discovered as a
result of #4366 was nasty - but I think it is unrelated. It happened only
because #4366 added a Boolean overload to DSL methods that otherwise accept
Conditions.

Best Regards,
Lukas

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to