Does (*UpdateQuery).Set() invalidate (*UpdateQuery).Column() ? #647
-
Hi, Due to #621, I plan to manually update type OAuth2State struct {
ID string `json:"id" bun:",pk"`
CreatedAt time.Time `bun:",nullzero,notnull,skipupdate,default:current_timestamp" json:"createdAt"`
UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp" json:"updatedAt"`
Mode OAuth2StateMode `json:"mode" bun:",notnull,nullzero"`
Status OAuth2Status `json:"status" bun:",notnull"`
}
func (op Operator) UpdateOAuth2StateStatusByID(ctx context.Context, id string, status OAuth2Status) (err error) {
state := OAuth2State{ID: id, Status: status}
err = assertAffectedOneRow(op.db.NewUpdate().
Model(&state).
Column("status").
Set("updated_at = current_timestamp").
WherePK().
Exec(ctx))
return
} But I found out the generated SQL only sets I digged into the source and got a little suprised: Lines 243 to 263 in efe03f4 So using Thanks and have a pleasant day! |
Beta Was this translation helpful? Give feedback.
Answered by
vmihailenco
Aug 21, 2022
Replies: 1 comment
-
This is expected, but we could try to change this behavior if there is enough interest. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nanmu42
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is expected, but we could try to change this behavior if there is enough interest.