Skip to content

Commit 18837ba

Browse files
committed
prefer to pass a sql.NullString to dbCrypt.encryptField
1 parent e2ca180 commit 18837ba

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

enterprise/dbcrypt/dbcrypt.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,14 @@ func (db *dbCrypt) UpdateExternalAuthLink(ctx context.Context, params database.U
262262
}
263263

264264
func (db *dbCrypt) UpdateExternalAuthLinkRefreshToken(ctx context.Context, params database.UpdateExternalAuthLinkRefreshTokenParams) error {
265-
if err := db.encryptField(&params.OAuthRefreshToken, &sql.NullString{String: params.OAuthRefreshTokenKeyID, Valid: true}); err != nil {
265+
// We would normally use a sql.NullString here, but sqlc does not want to make
266+
// a params struct with a nullable string.
267+
var digest sql.NullString
268+
if params.OAuthRefreshTokenKeyID != "" {
269+
digest.String = params.OAuthRefreshTokenKeyID
270+
digest.Valid = true
271+
}
272+
if err := db.encryptField(&params.OAuthRefreshToken, &digest); err != nil {
266273
return err
267274
}
268275

0 commit comments

Comments
 (0)