Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Meta.equals() and hashCode() based on Meta.ddl() #9433

Closed
lukaseder opened this issue Oct 23, 2019 · 2 comments

Comments

@lukaseder
Copy link
Member

@lukaseder lukaseder commented Oct 23, 2019

In addition to the debugging utility introduced with #9428, we should also allow for comparing two Meta implementations based on their produced ddl()

If two Meta instances are equal, then their diff is empty:

Meta m1 = ...
Meta m2 = ...

if (m1.equals(m2)) {
  assertEquals(0, m1.diff(m2))
  assertEquals(0, m2.diff(m1))
}

Unlike in the debugging utility #9428, we're not adding any performance considerations here. If users want to compare equality, then they will be willing to pay the price if the specific Meta implementation originates from a JDBC DatabaseMetaData set of queries.

@lukaseder

This comment has been minimized.

Copy link
Member Author

@lukaseder lukaseder commented Oct 23, 2019

There's some subtlety to think about here. Are these two tables equal?

create table t (a int, b int);
create table t (b int, a int);

They could be seen equal or not. Both options are possible. Also, are these two databases equal?

-- DB1
create schema s1;
create schema s2;

-- DB2
create schema s2;
create schema s1;

In the latter case, we could argue that Meta.ddl() should produce schemas in a predictable order.

We can fix both of these things via: #9434

@lukaseder

This comment has been minimized.

Copy link
Member Author

@lukaseder lukaseder commented Oct 23, 2019

We won't reorder the columns but use the new defaults for #9434. This fixes the schema order but not the column order.

@lukaseder lukaseder closed this Oct 23, 2019
3.13 DDL interpretation automation moved this from To do to Done Oct 23, 2019
@lukaseder lukaseder self-assigned this Oct 23, 2019
@lukaseder lukaseder added the R: Fixed label Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.