[jOOQ/jOOQ#14371] Slow TableAlias::equals implementation, when argument type is TableImpl
This commit is contained in:
parent
9fb447315f
commit
4838334495
@ -62,7 +62,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class TableAlias<R extends Record> extends AbstractTable<R> implements QOM.TableAlias<R>, SimpleCheckQueryPart {
|
||||
final class TableAlias<R extends Record>
|
||||
extends
|
||||
AbstractTable<R>
|
||||
implements
|
||||
QOM.TableAlias<R>,
|
||||
SimpleCheckQueryPart
|
||||
{
|
||||
|
||||
final Alias<Table<R>> alias;
|
||||
transient FieldsImpl<R> aliasedFields;
|
||||
@ -223,9 +229,22 @@ final class TableAlias<R extends Record> extends AbstractTable<R> implements QOM
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof TableAlias)
|
||||
return getUnqualifiedName().equals(((TableAlias<?>) that).getUnqualifiedName());
|
||||
else
|
||||
return super.equals(that);
|
||||
if (this == that)
|
||||
return true;
|
||||
|
||||
if (that instanceof TableAlias<?> t)
|
||||
return getUnqualifiedName().equals(t.getUnqualifiedName());
|
||||
|
||||
// [#14371] Unqualified TableImpls can be equal to TableAlias
|
||||
if (that instanceof TableImpl<?> t) {
|
||||
if (t.$alias() != null)
|
||||
return getUnqualifiedName().equals(t.$alias());
|
||||
|
||||
// [#7172] [#10274] Cannot use getQualifiedName() yet here
|
||||
else if (t.getSchema() == null)
|
||||
return getUnqualifiedName().equals(t.getQualifiedName());
|
||||
}
|
||||
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,16 +530,27 @@ implements
|
||||
|
||||
// [#2144] TableImpl equality can be decided without executing the
|
||||
// rather expensive implementation of AbstractQueryPart.equals()
|
||||
if (that instanceof TableImpl<?> other) {
|
||||
if (that instanceof TableImpl<?> t) {
|
||||
return
|
||||
|
||||
// [#7172] [#10274] Cannot use getQualifiedName() yet here
|
||||
StringUtils.equals(
|
||||
defaultIfNull(getSchema(), DEFAULT_SCHEMA),
|
||||
defaultIfNull(other.getSchema(), DEFAULT_SCHEMA)
|
||||
defaultIfNull(t.getSchema(), DEFAULT_SCHEMA)
|
||||
) &&
|
||||
StringUtils.equals(getName(), other.getName()) &&
|
||||
Arrays.equals(parameters, other.parameters);
|
||||
StringUtils.equals(getName(), t.getName()) &&
|
||||
Arrays.equals(parameters, t.parameters);
|
||||
}
|
||||
|
||||
// [#14371] Unqualified TableImpls can be equal to TableAlias
|
||||
else if (that instanceof TableAlias<?> t) {
|
||||
|
||||
if ($alias() != null)
|
||||
return t.getUnqualifiedName().equals($alias());
|
||||
|
||||
// [#7172] [#10274] Cannot use getQualifiedName() yet here
|
||||
else if (getSchema() == null)
|
||||
return t.getUnqualifiedName().equals(getQualifiedName());
|
||||
}
|
||||
|
||||
return super.equals(that);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user