overrides

This commit is contained in:
2026-09-06 19:22:47 +02:00
parent 2dc9a30644
commit 629d515911
5 changed files with 340 additions and 21 deletions
+5 -4
View File
@@ -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
}