gorm icon indicating copy to clipboard operation
gorm copied to clipboard

Fix null setting on reused objects

Open turip opened this issue 1 year ago • 1 comments

  • [x] Do only one thing
  • [x] Non breaking API changes
  • [ ] Tested

What did this pull request do?

Starting from v1.25.1 GORM seems to not reset null fields, causing incosistent behavior compared to the previous way GORM was working.

The fixes I have added are fixing this for Scanner interfaces and time.Time, however there's still a test failure in case of the int and most likely other primitive variables.

I am opening this PR just to illustrate the fixes, but I think we need to debate it further what's the expected behavior.

User Case Description

turip avatar Feb 13 '24 18:02 turip

The regression seems to be coming from this PR: https://github.com/go-gorm/gorm/pull/6311

The unit tests are still failing on the integer default value setting. I can dig that out too @jinzhu, but this partially reverts #6311. What do you think about this fix?

turip avatar Feb 13 '24 18:02 turip

This PR is being closed due to failed tests.

jinzhu avatar Apr 26 '24 07:04 jinzhu