overrides
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// PgKeyStore adapts the sqlc-generated queries to the KeyStore interface.
|
||||
//
|
||||
// The indirection earns its keep twice: the middleware is testable without a
|
||||
// database, and adding an unrelated column to api.keys does not ripple into the
|
||||
// auth package.
|
||||
@@ -38,10 +39,10 @@ func (s PgKeyStore) KeyByHash(ctx context.Context, hash []byte) (KeyRecord, erro
|
||||
OwnerStatus: row.OwnerStatus,
|
||||
}
|
||||
|
||||
// sqlc with emit_pointers_for_null_types gives *time.Time for a nullable
|
||||
// timestamptz. If your generated code uses pgtype.Timestamptz instead,
|
||||
// convert here rather than in the middleware.
|
||||
rec.ExpiresAt = row.ExpiresAt
|
||||
// pgx maps a nullable timestamptz to pgtype.Timestamptz, which carries its
|
||||
// own validity flag rather than being nil. db.Time does the conversion so
|
||||
// pgtype never leaks past this adapter.
|
||||
rec.ExpiresAt = db.Time(row.ExpiresAt)
|
||||
|
||||
return rec, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user