mirror of https://github.com/jackc/pgx.git
Rename pgtype.None to pgtype.Finite
parent
1f2f239d09
commit
f3defbc150
|
@ -368,7 +368,7 @@ func (w *timeWrapper) ScanDate(v Date) error {
|
|||
}
|
||||
|
||||
switch v.InfinityModifier {
|
||||
case None:
|
||||
case Finite:
|
||||
*w = timeWrapper(v.Time)
|
||||
return nil
|
||||
case Infinity:
|
||||
|
@ -390,7 +390,7 @@ func (w *timeWrapper) ScanTimestamp(v Timestamp) error {
|
|||
}
|
||||
|
||||
switch v.InfinityModifier {
|
||||
case None:
|
||||
case Finite:
|
||||
*w = timeWrapper(v.Time)
|
||||
return nil
|
||||
case Infinity:
|
||||
|
@ -412,7 +412,7 @@ func (w *timeWrapper) ScanTimestamptz(v Timestamptz) error {
|
|||
}
|
||||
|
||||
switch v.InfinityModifier {
|
||||
case None:
|
||||
case Finite:
|
||||
*w = timeWrapper(v.Time)
|
||||
return nil
|
||||
case Infinity:
|
||||
|
|
|
@ -62,7 +62,7 @@ func (src Date) Value() (driver.Value, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
if src.InfinityModifier != None {
|
||||
if src.InfinityModifier != Finite {
|
||||
return src.InfinityModifier.String(), nil
|
||||
}
|
||||
return src.Time, nil
|
||||
|
@ -76,7 +76,7 @@ func (src Date) MarshalJSON() ([]byte, error) {
|
|||
var s string
|
||||
|
||||
switch src.InfinityModifier {
|
||||
case None:
|
||||
case Finite:
|
||||
s = src.Time.Format("2006-01-02")
|
||||
case Infinity:
|
||||
s = "infinity"
|
||||
|
@ -155,7 +155,7 @@ func (encodePlanDateCodecBinary) Encode(value interface{}, buf []byte) (newBuf [
|
|||
|
||||
var daysSinceDateEpoch int32
|
||||
switch date.InfinityModifier {
|
||||
case None:
|
||||
case Finite:
|
||||
tUnix := time.Date(date.Time.Year(), date.Time.Month(), date.Time.Day(), 0, 0, 0, 0, time.UTC).Unix()
|
||||
dateEpoch := time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC).Unix()
|
||||
|
||||
|
@ -185,7 +185,7 @@ func (encodePlanDateCodecText) Encode(value interface{}, buf []byte) (newBuf []b
|
|||
var s string
|
||||
|
||||
switch date.InfinityModifier {
|
||||
case None:
|
||||
case Finite:
|
||||
s = date.Time.Format("2006-01-02")
|
||||
case Infinity:
|
||||
s = "infinity"
|
||||
|
@ -282,7 +282,7 @@ func (c DateCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte) (in
|
|||
|
||||
if date.Valid {
|
||||
switch date.InfinityModifier {
|
||||
case None:
|
||||
case Finite:
|
||||
return date.Time, nil
|
||||
case Infinity:
|
||||
return "infinity", nil
|
||||
|
|
|
@ -42,7 +42,7 @@ func isExpectedEqNumeric(a interface{}) func(interface{}) bool {
|
|||
}
|
||||
|
||||
// If NaN or InfinityModifier are set then Int and Exp don't matter.
|
||||
if aa.NaN || aa.InfinityModifier != pgtype.None {
|
||||
if aa.NaN || aa.InfinityModifier != pgtype.Finite {
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -109,14 +109,14 @@ type InfinityModifier int8
|
|||
|
||||
const (
|
||||
Infinity InfinityModifier = 1
|
||||
None InfinityModifier = 0
|
||||
Finite InfinityModifier = 0
|
||||
NegativeInfinity InfinityModifier = -Infinity
|
||||
)
|
||||
|
||||
func (im InfinityModifier) String() string {
|
||||
switch im {
|
||||
case None:
|
||||
return "none"
|
||||
case Finite:
|
||||
return "finite"
|
||||
case Infinity:
|
||||
return "infinity"
|
||||
case NegativeInfinity:
|
||||
|
|
|
@ -59,7 +59,7 @@ func (ts Timestamp) Value() (driver.Value, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
if ts.InfinityModifier != None {
|
||||
if ts.InfinityModifier != Finite {
|
||||
return ts.InfinityModifier.String(), nil
|
||||
}
|
||||
return ts.Time, nil
|
||||
|
@ -104,7 +104,7 @@ func (encodePlanTimestampCodecBinary) Encode(value interface{}, buf []byte) (new
|
|||
|
||||
var microsecSinceY2K int64
|
||||
switch ts.InfinityModifier {
|
||||
case None:
|
||||
case Finite:
|
||||
t := discardTimeZone(ts.Time)
|
||||
microsecSinceUnixEpoch := t.Unix()*1000000 + int64(t.Nanosecond())/1000
|
||||
microsecSinceY2K = microsecSinceUnixEpoch - microsecFromUnixEpochToY2K
|
||||
|
@ -130,7 +130,7 @@ func (encodePlanTimestampCodecText) Encode(value interface{}, buf []byte) (newBu
|
|||
var s string
|
||||
|
||||
switch ts.InfinityModifier {
|
||||
case None:
|
||||
case Finite:
|
||||
t := discardTimeZone(ts.Time)
|
||||
s = t.Truncate(time.Microsecond).Format(pgTimestampFormat)
|
||||
case Infinity:
|
||||
|
@ -241,7 +241,7 @@ func (c TimestampCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int16,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if ts.InfinityModifier != None {
|
||||
if ts.InfinityModifier != Finite {
|
||||
return ts.InfinityModifier.String(), nil
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ func (c TimestampCodec) DecodeValue(m *Map, oid uint32, format int16, src []byte
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if ts.InfinityModifier != None {
|
||||
if ts.InfinityModifier != Finite {
|
||||
return ts.InfinityModifier, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ func (tstz Timestamptz) Value() (driver.Value, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
if tstz.InfinityModifier != None {
|
||||
if tstz.InfinityModifier != Finite {
|
||||
return tstz.InfinityModifier.String(), nil
|
||||
}
|
||||
return tstz.Time, nil
|
||||
|
@ -82,7 +82,7 @@ func (tstz Timestamptz) MarshalJSON() ([]byte, error) {
|
|||
var s string
|
||||
|
||||
switch tstz.InfinityModifier {
|
||||
case None:
|
||||
case Finite:
|
||||
s = tstz.Time.Format(time.RFC3339Nano)
|
||||
case Infinity:
|
||||
s = "infinity"
|
||||
|
@ -162,7 +162,7 @@ func (encodePlanTimestamptzCodecBinary) Encode(value interface{}, buf []byte) (n
|
|||
|
||||
var microsecSinceY2K int64
|
||||
switch ts.InfinityModifier {
|
||||
case None:
|
||||
case Finite:
|
||||
microsecSinceUnixEpoch := ts.Time.Unix()*1000000 + int64(ts.Time.Nanosecond())/1000
|
||||
microsecSinceY2K = microsecSinceUnixEpoch - microsecFromUnixEpochToY2K
|
||||
case Infinity:
|
||||
|
@ -187,7 +187,7 @@ func (encodePlanTimestamptzCodecText) Encode(value interface{}, buf []byte) (new
|
|||
var s string
|
||||
|
||||
switch ts.InfinityModifier {
|
||||
case None:
|
||||
case Finite:
|
||||
s = ts.Time.UTC().Truncate(time.Microsecond).Format(pgTimestamptzSecondFormat)
|
||||
case Infinity:
|
||||
s = "infinity"
|
||||
|
@ -298,7 +298,7 @@ func (c TimestamptzCodec) DecodeDatabaseSQLValue(m *Map, oid uint32, format int1
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if tstz.InfinityModifier != None {
|
||||
if tstz.InfinityModifier != Finite {
|
||||
return tstz.InfinityModifier.String(), nil
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ func (c TimestamptzCodec) DecodeValue(m *Map, oid uint32, format int16, src []by
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if tstz.InfinityModifier != None {
|
||||
if tstz.InfinityModifier != Finite {
|
||||
return tstz.InfinityModifier, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ func (ts *Timestamp) ScanTimestamp(v pgtype.Timestamp) error {
|
|||
}
|
||||
|
||||
switch v.InfinityModifier {
|
||||
case pgtype.None:
|
||||
case pgtype.Finite:
|
||||
*ts = Timestamp(v.Time)
|
||||
return nil
|
||||
case pgtype.Infinity:
|
||||
|
|
|
@ -19,7 +19,7 @@ func (ts *Timestamptz) ScanTimestamptz(v pgtype.Timestamptz) error {
|
|||
}
|
||||
|
||||
switch v.InfinityModifier {
|
||||
case pgtype.None:
|
||||
case pgtype.Finite:
|
||||
*ts = Timestamptz(v.Time)
|
||||
return nil
|
||||
case pgtype.Infinity:
|
||||
|
|
Loading…
Reference in New Issue