Skip to content

Commit

Permalink
db.Now() returns time.Now() in case of an error
Browse files Browse the repository at this point in the history
  • Loading branch information
ungerik committed Nov 21, 2024
1 parent 2f785c1 commit 74b63c7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions db/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ import (
// function for the current connection.
// Useful for getting the timestamp of a
// SQL transaction for use in Go code.
func Now(ctx context.Context) (time.Time, error) {
return Conn(ctx).Now()
// Returns time.Now() in case of an error.
func Now(ctx context.Context) time.Time {
now, err := Conn(ctx).Now()
if err != nil {
return time.Now()
}
return now
}

// Exec executes a query with optional args.
Expand Down

0 comments on commit 74b63c7

Please sign in to comment.