Skip to content

Commit

Permalink
[typing] Log if we observe a precision with a value of zero (#780)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-artie authored Jun 28, 2024
1 parent be4ebf0 commit 642d652
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/typing/decimal/details.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package decimal

import (
"fmt"
"log/slog"
)

const (
Expand All @@ -17,6 +18,13 @@ type Details struct {
}

func NewDetails(precision int32, scale int32) Details {
if precision == 0 {
// MySQL, PostgreSQL, and SQLServer do not allow a zero precision, so this should never happen.
// Let's log if we observe it happening, and if we don't see it in the logs then we can use zero as the
// [PrecisionNotSpecified] value and change precision to a uint16.
slog.Error("Decimal precision is zero")
}

if scale > precision && precision != PrecisionNotSpecified {
// Note: -1 precision means it's not specified.

Expand Down

0 comments on commit 642d652

Please sign in to comment.