daichirata / hammer

🛠 hammer is a command-line tool to schema management for Google Cloud Spanner.
MIT License
84 stars 25 forks source link

fix timestamp with default values comparison #54

Closed reedom closed 1 year ago

reedom commented 1 year ago

If both sides have identical columns of timestamp with a default value,

CREATE TABLE  (
  column TIMESTAMP NOT NULL DEFAULT(TIMESTAMP '2000-01-01 00:00:00.000000+00:00'),
  …

it panics:

panic: cannot handle unexported field at {spansql.ColumnDef}.Default.(spansql.TimestampLiteral).wall:
    "cloud.google.com/go/spanner/spansql".TimestampLiteral
consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported [recovered]
    panic: cannot handle unexported field at {spansql.ColumnDef}.Default.(spansql.TimestampLiteral).wall:
    "cloud.google.com/go/spanner/spansql".TimestampLiteral
consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported

test that reproduces:

https://github.com/murasaki-bv/hammer/blob/f8af0e9e7cd4b06716aee0fdffe46c21db6aa690/internal/hammer/diff_test.go#L1364-L1381

daichirata commented 1 year ago

Thank you for fixing the problem! I appreciate your contribution.