Skip to content

Commit

Permalink
Merge pull request #1453 from ydb-platform/param-builder-optional
Browse files Browse the repository at this point in the history
nullable value within parambuilder
  • Loading branch information
asmyasnikov authored Sep 18, 2024
2 parents 9cd2f73 + bc541e0 commit 1a5e570
Show file tree
Hide file tree
Showing 6 changed files with 446 additions and 161 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* Fixed bug in experimental api: `ydb.ParamsBuilder().Param().Optional()` receive pointer and really produce optional value.

## v3.80.8
* Added `ydb.WithLazyTx(bool)` option for create lazy transactions on `query.Session.Begin` call
* Added initial experimental topic and cdc-helpers, see examples in [tests/integration/topic_helpers_test.go](https://github.com/ydb-platform/ydb-go-sdk/blob/master/tests/integration/topic_helpers_test.go)
Expand Down
100 changes: 50 additions & 50 deletions internal/params/optional.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,152 +27,152 @@ func (b *optionalBuilder) EndOptional() Builder {
return b.opt.parent
}

func (p *optional) Text(v string) *optionalBuilder {
p.value = value.TextValue(v)
func (p *optional) Text(v *string) *optionalBuilder {
p.value = value.NullableTextValue(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Bytes(v []byte) *optionalBuilder {
p.value = value.BytesValue(v)
func (p *optional) Bytes(v *[]byte) *optionalBuilder {
p.value = value.NullableBytesValue(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Bool(v bool) *optionalBuilder {
p.value = value.BoolValue(v)
func (p *optional) Bool(v *bool) *optionalBuilder {
p.value = value.NullableBoolValue(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Uint64(v uint64) *optionalBuilder {
p.value = value.Uint64Value(v)
func (p *optional) Uint64(v *uint64) *optionalBuilder {
p.value = value.NullableUint64Value(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Int64(v int64) *optionalBuilder {
p.value = value.Int64Value(v)
func (p *optional) Int64(v *int64) *optionalBuilder {
p.value = value.NullableInt64Value(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Uint32(v uint32) *optionalBuilder {
p.value = value.Uint32Value(v)
func (p *optional) Uint32(v *uint32) *optionalBuilder {
p.value = value.NullableUint32Value(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Int32(v int32) *optionalBuilder {
p.value = value.Int32Value(v)
func (p *optional) Int32(v *int32) *optionalBuilder {
p.value = value.NullableInt32Value(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Uint16(v uint16) *optionalBuilder {
p.value = value.Uint16Value(v)
func (p *optional) Uint16(v *uint16) *optionalBuilder {
p.value = value.NullableUint16Value(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Int16(v int16) *optionalBuilder {
p.value = value.Int16Value(v)
func (p *optional) Int16(v *int16) *optionalBuilder {
p.value = value.NullableInt16Value(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Uint8(v uint8) *optionalBuilder {
p.value = value.Uint8Value(v)
func (p *optional) Uint8(v *uint8) *optionalBuilder {
p.value = value.NullableUint8Value(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Int8(v int8) *optionalBuilder {
p.value = value.Int8Value(v)
func (p *optional) Int8(v *int8) *optionalBuilder {
p.value = value.NullableInt8Value(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Float(v float32) *optionalBuilder {
p.value = value.FloatValue(v)
func (p *optional) Float(v *float32) *optionalBuilder {
p.value = value.NullableFloatValue(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Double(v float64) *optionalBuilder {
p.value = value.DoubleValue(v)
func (p *optional) Double(v *float64) *optionalBuilder {
p.value = value.NullableDoubleValue(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Decimal(v [16]byte, precision, scale uint32) *optionalBuilder {
p.value = value.DecimalValue(v, precision, scale)
func (p *optional) Decimal(v *[16]byte, precision, scale uint32) *optionalBuilder {
p.value = value.NullableDecimalValue(v, precision, scale)

return &optionalBuilder{opt: p}
}

func (p *optional) Timestamp(v time.Time) *optionalBuilder {
p.value = value.TimestampValueFromTime(v)
func (p *optional) Timestamp(v *time.Time) *optionalBuilder {
p.value = value.NullableTimestampValueFromTime(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Date(v time.Time) *optionalBuilder {
p.value = value.DateValueFromTime(v)
func (p *optional) Date(v *time.Time) *optionalBuilder {
p.value = value.NullableDateValueFromTime(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Datetime(v time.Time) *optionalBuilder {
p.value = value.DatetimeValueFromTime(v)
func (p *optional) Datetime(v *time.Time) *optionalBuilder {
p.value = value.NullableDatetimeValueFromTime(v)

return &optionalBuilder{opt: p}
}

func (p *optional) Interval(v time.Duration) *optionalBuilder {
p.value = value.IntervalValueFromDuration(v)
func (p *optional) Interval(v *time.Duration) *optionalBuilder {
p.value = value.NullableIntervalValueFromDuration(v)

return &optionalBuilder{opt: p}
}

func (p *optional) JSON(v string) *optionalBuilder {
p.value = value.JSONValue(v)
func (p *optional) JSON(v *string) *optionalBuilder {
p.value = value.NullableJSONValue(v)

return &optionalBuilder{opt: p}
}

func (p *optional) JSONDocument(v string) *optionalBuilder {
p.value = value.JSONDocumentValue(v)
func (p *optional) JSONDocument(v *string) *optionalBuilder {
p.value = value.NullableJSONDocumentValue(v)

return &optionalBuilder{opt: p}
}

func (p *optional) YSON(v []byte) *optionalBuilder {
p.value = value.YSONValue(v)
func (p *optional) YSON(v *[]byte) *optionalBuilder {
p.value = value.NullableYSONValueFromBytes(v)

return &optionalBuilder{opt: p}
}

func (p *optional) UUID(v [16]byte) *optionalBuilder {
p.value = value.UUIDValue(v)
func (p *optional) UUID(v *[16]byte) *optionalBuilder {
p.value = value.NullableUUIDValue(v)

return &optionalBuilder{opt: p}
}

func (p *optional) TzDate(v time.Time) *optionalBuilder {
p.value = value.TzDateValueFromTime(v)
func (p *optional) TzDate(v *time.Time) *optionalBuilder {
p.value = value.NullableTzDateValueFromTime(v)

return &optionalBuilder{opt: p}
}

func (p *optional) TzTimestamp(v time.Time) *optionalBuilder {
p.value = value.TzTimestampValueFromTime(v)
func (p *optional) TzTimestamp(v *time.Time) *optionalBuilder {
p.value = value.NullableTzTimestampValueFromTime(v)

return &optionalBuilder{opt: p}
}

func (p *optional) TzDatetime(v time.Time) *optionalBuilder {
p.value = value.TzDatetimeValueFromTime(v)
func (p *optional) TzDatetime(v *time.Time) *optionalBuilder {
p.value = value.NullableTzDatetimeValueFromTime(v)

return &optionalBuilder{opt: p}
}
Loading

0 comments on commit 1a5e570

Please sign in to comment.