Skip to content

Commit 672a337

Browse files
committed
deprecated the constructors of interval value from int64
1 parent 363606d commit 672a337

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* Fixed bug with convert ydb value to `time.Duration` in `result.Scan[WithDefaults,Named]()`
22
* Fixed bug with make ydb value from `time.Duration` in `types.IntervalValueFromDuration(d)`
3+
* Marked `table/types.{IntervalValue,NullableIntervalValue}` as deprecated
34

45
## v3.26.8
56
* Removed the processing of trailer metadata on stream calls

table/types/value.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ func DatetimeValue(v uint32) Value { return value.DatetimeValue(v) }
4242

4343
func TimestampValue(v uint64) Value { return value.TimestampValue(v) }
4444

45+
// IntervalValueFromMicroseconds makes Value from given microseconds value
46+
func IntervalValueFromMicroseconds(v int64) Value { return value.IntervalValue(v) }
47+
4548
// IntervalValue makes Value from given microseconds value
49+
//
50+
// Deprecated: use IntervalValueFromMicroseconds instead
4651
func IntervalValue(v int64) Value { return value.IntervalValue(v) }
4752

4853
// TzDateValue makes TzDate value from string
@@ -392,13 +397,23 @@ func NullableTzTimestampValueFromTime(v *time.Time) Value {
392397
return OptionalValue(TzTimestampValueFromTime(*v))
393398
}
394399

400+
// NullableIntervalValue makes Value which maybe nil or valued
401+
//
402+
// Deprecated: use NullableIntervalValueFromMicroseconds instead
395403
func NullableIntervalValue(v *int64) Value {
396404
if v == nil {
397405
return NullValue(TypeInterval)
398406
}
399407
return OptionalValue(IntervalValue(*v))
400408
}
401409

410+
func NullableIntervalValueFromMicroseconds(v *int64) Value {
411+
if v == nil {
412+
return NullValue(TypeInterval)
413+
}
414+
return OptionalValue(IntervalValueFromMicroseconds(*v))
415+
}
416+
402417
func NullableIntervalValueFromDuration(v *time.Duration) Value {
403418
if v == nil {
404419
return NullValue(TypeInterval)
@@ -540,7 +555,7 @@ func Nullable(t Type, v interface{}) Value {
540555
case TypeInterval:
541556
switch tt := v.(type) {
542557
case *int64:
543-
return NullableIntervalValue(tt)
558+
return NullableIntervalValueFromMicroseconds(tt)
544559
case *time.Duration:
545560
return NullableIntervalValueFromDuration(tt)
546561
default:

table/types/value_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ func TestNullable(t *testing.T) {
217217
exp: NullValue(TypeTzDate),
218218
},
219219
{
220-
name: "interval from int32",
220+
name: "interval from int64",
221221
t: TypeInterval,
222222
v: func(v int64) *int64 { return &v }(123),
223-
exp: OptionalValue(IntervalValue(123)),
223+
exp: OptionalValue(IntervalValueFromMicroseconds(123)),
224224
},
225225
{
226226
name: "interval from time.Time",

0 commit comments

Comments
 (0)