Skip to content

Commit

Permalink
Don't check column names on H2 results for correctness tests as descr…
Browse files Browse the repository at this point in the history
…ibed in #1667 (comment).

Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
  • Loading branch information
Yury-Fridlyand committed Jun 23, 2023
1 parent fc2026a commit 62bc46b
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import lombok.EqualsAndHashCode;
import java.util.stream.Collectors;
import lombok.Getter;
import lombok.ToString;
import org.json.JSONPropertyName;
Expand All @@ -24,7 +25,6 @@
* query with SELECT columns or just *, order of column and row may matter or not. So the internal data structure of this
* class is passed in from outside either list or set, hash map or linked hash map etc.
*/
@EqualsAndHashCode(exclude = "databaseName")
@ToString
public class DBResult {

Expand Down Expand Up @@ -191,4 +191,22 @@ private static <T extends Comparable<T>> List<T> sort(Collection<T> collection)
return list;
}

public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof DBResult)) {
return false;
}
final DBResult other = (DBResult) o;
// H2 calculates the value before setting column name
// for example, for query "select 1 + 1" it returns a column named "2" instead of "1 + 1"
boolean skipColumnNameCheck = databaseName.equalsIgnoreCase("h2") || other.databaseName.equalsIgnoreCase("h2");
if ((!skipColumnNameCheck && !schema.equals(other.schema) || (skipColumnNameCheck &&
!schema.stream().map(Type::getType).collect(Collectors.toList())
.equals(other.schema.stream().map(Type::getType).collect(Collectors.toList()))))) {
return false;
}
return dataRows.equals(other.dataRows);
}
}

0 comments on commit 62bc46b

Please sign in to comment.