Your Question

After updating from * gorm.io/driver/postgres v1.2.3 * gorm.io/gorm v1.22.5

to

  • gorm.io/driver/postgres v1.3.1
  • gorm.io/gorm v1.23.1

I experience weird behavior calling the .Save() method, I get an error "cannot convert enter unix timestamp here to Timestamp", which I can track back to the UpdatedAt column. Also my unit tests in that regard fail because instead of previously a time.Time type was expected for the UpdatedAt column, but with the new version the column expects the type to be int64. After reverting back to the old version everything is working again. Is this some unexpected breaking change or a bug in the last release?

Comment From: jinzhu

Can you added a reproducible playground PR?

Comment From: tfonfara

@jinzhu done: https://github.com/go-gorm/playground/pull/438

It seems that this is somehow related to the field type. Steps to reproduce: 1. In go.mod use the version set with gorm v1.22.5 2. Run GORM_DIALECT=postgres go test 3. Tests will pass ✅ 4. In go.mod use the version set with gorm v1.23.1 5. Run GORM_DIALECT=postgres go test 6. Tests will fail ❌

You can also see the difference in the query:

v1.22.5:

UPDATE "users" SET "created_at"='2022-02-22 10:53:01.738',"updated_at"='2022-02-22 10:53:01.738',...

v1.23.1:

UPDATE "users" SET "created_at"='2022-02-22 10:53:01.738',"updated_at"=1645523581,...

The created_at field (which has the same field type) has no issues, but the updated_at field.

Comment From: jamestown27

After pulling the latest version 1.23.1 I started seeing the same issue as @tfonfara with MySQL also. 1.22.4 / 1.22.5 doesn't have this issue.

Comment From: jinzhu

Fixed, thank you for your report, you can remove the type tag for the struct to make it works or use the latest master

Sorry for the issue.

Comment From: tfonfara

Fix confirmed, thanks for the fast reaction!