[#4724] Comparison shouldn't be based on primary keys

This commit is contained in:
lukaseder 2016-05-03 06:50:32 +02:00
parent d1fcd7c102
commit eaec9e00fe
2 changed files with 13 additions and 33 deletions

View File

@ -1596,13 +1596,10 @@ public interface Table<R extends Record> extends TableLike<R> {
/**
* Create a predicate comparing records from self-joined tables.
* <p>
* This is a convenience method for self-joins, comparing either:
* <ul>
* <li>Primary key values, if {@link #getPrimaryKey()} is available</li>
* <li>Complete records, otherwise</li>
* </ul>
* For example:
* <code><pre>
* This is a convenience method for self-joins, comparing complete records
* between tables.
* <p>
* For example: <code><pre>
* MyTable a = MY_TABLE.as("a");
* MyTable b = MY_TABLE.as("b");
*
@ -1620,11 +1617,9 @@ public interface Table<R extends Record> extends TableLike<R> {
/**
* Create a predicate comparing records from self-joined tables.
* <p>
* This is a convenience method for self-joins, comparing either:
* <ul>
* <li>Primary key values, if {@link #getPrimaryKey()} is available</li>
* <li>Complete records, otherwise</li>
* </ul>
* This is a convenience method for self-joins, comparing complete records
* between tables.
* <p>
* For example:
* <code><pre>
* MyTable a = MY_TABLE.as("a");
@ -1650,12 +1645,9 @@ public interface Table<R extends Record> extends TableLike<R> {
/**
* Create a predicate comparing records from self-non-equi-joined tables.
* This is a convenience method for self-joins, comparing complete records
* between tables.
* <p>
* This is a convenience method for self-non-equi-joins, comparing either:
* <ul>
* <li>Primary key values, if {@link #getPrimaryKey()} is available</li>
* <li>Complete records, otherwise</li>
* </ul>
* For example:
* <code><pre>
* MyTable a = MY_TABLE.as("a");
@ -1675,11 +1667,9 @@ public interface Table<R extends Record> extends TableLike<R> {
/**
* Create a predicate comparing records from self-non-equi-joined tables.
* <p>
* This is a convenience method for self-non-equi-joins, comparing either:
* <ul>
* <li>Primary key values, if {@link #getPrimaryKey()} is available</li>
* <li>Complete records, otherwise</li>
* </ul>
* This is a convenience method for self-joins, comparing complete records
* between tables.
* <p>
* For example:
* <code><pre>
* MyTable a = MY_TABLE.as("a");

View File

@ -47,7 +47,6 @@ import org.jooq.Comparator;
import org.jooq.Context;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.UniqueKey;
/**
* @author Lukas Eder
@ -77,16 +76,7 @@ final class TableComparison<R extends Record> extends AbstractCondition {
}
default: {
UniqueKey<R> lhsPK = lhs.getPrimaryKey();
UniqueKey<R> rhsPK = rhs.getPrimaryKey();
if (lhsPK != null && rhsPK != null && lhsPK.getTable().equals(rhsPK.getTable())) {
ctx.visit(row(lhs.fields(lhsPK.getFieldsArray())).compare(comparator, row(rhs.fields(rhsPK.getFieldsArray()))));
}
else {
ctx.visit(row(lhs.fields()).compare(comparator, row(rhs.fields())));
}
ctx.visit(row(lhs.fields()).compare(comparator, row(rhs.fields())));
break;
}
}