GORM Playground Link

I will add the link later, can't do it now, but I think the description is enough to understand the issue: https://github.com/go-gorm/playground

Description

I'm using the following code to create a thread_update. See that I'm passing the UpdatedAt value.

    property := models.ThreadProperty{
        ThreadID:  threadId,
        Key:       key,
        Value:     value,
        UserID:    thread.UserID,
        UpdatedAt: time.Now().UTC(),
    }

    if err := dbClient.ThreadProperty.Save(&property); err != nil {
        return fmt.Errorf("failed to save property [key: %v | value: %v]: %w", key, value, err)
    }

The generated SQL is as below. See that the UpdatedAt passed to VALUES is 12:55, which is correctly set to UTC, but the UPDATE SET clause for updated_at has my local time 09:55.

INSERT INTO
    "thread_properties" (
        "thread_id",
        "key",
        "value",
        "metadata",
        "updated_at",
        "user_id"
    )
VALUES
    (
        '059f5bd0-531a-4752-9587-99c2f42518a7',
        'relevance',
        '{"relevance":"urgent","description":"stub desc","why_matters":"stub why matters"}',
        NULL,
        '2024-10-14 12:55:44.891', # This is UTC and the value I passed
        'cb3e9edc-9c5f-406d-820f-d4496f821d2e'
    ) ON CONFLICT ("thread_id", "key")
DO
UPDATE
SET
    "updated_at" = '2024-10-14 09:55:44.891', # This isn't UTC and not the value I passed in
    "value" = "excluded"."value",
    "metadata" = "excluded"."metadata",
    "user_id" = "excluded"."user_id"

Expectation

It should be using the value I passed in for UpdatedAt both for in VALUES and UPDATE SET.

"Quick-fix" (not exactly...)

If you have a the same problem with UpdatedAt, you can pass a function to gorm.Open to use UTC (or whatever timezone) as a configuration:

       instance, err := gorm.Open(postgres.Open(dsn), &gorm.Config{
        NowFunc: func() time.Time {
            return time.Now().UTC()
        },
    })