diff --git a/CHANGELOG.md b/CHANGELOG.md index cd3354b..a5e77b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Changed +- bump `go-tarantool` dependency to `v2`. + ## [0.1.0] - 2023-09-08 ### Changed diff --git a/converter.go b/converter.go index 71b1c65..0daf98b 100644 --- a/converter.go +++ b/converter.go @@ -9,8 +9,8 @@ import ( "time" "github.com/google/uuid" - "github.com/tarantool/go-tarantool/datetime" - "github.com/tarantool/go-tarantool/decimal" + "github.com/tarantool/go-tarantool/v2/datetime" + "github.com/tarantool/go-tarantool/v2/decimal" ) // Converter is a converter from S to T. @@ -33,8 +33,8 @@ var ( _ Converter[string, any] = (*IdentityConverter[string])(nil) _ Converter[string, any] = (*StringToIntervalConverter)(nil) - _ Converter[*datetime.Datetime, string] = (*DatetimeToStringConverter)(nil) - _ Converter[datetime.Interval, string] = (*IntervalToStringConverter)(nil) + _ Converter[datetime.Datetime, string] = (*DatetimeToStringConverter)(nil) + _ Converter[datetime.Interval, string] = (*IntervalToStringConverter)(nil) ) // IdentityConverter is a converter from S to any, that doesn't change the input. @@ -164,7 +164,7 @@ func MakeStringToDecimalConverter(ignoreChars, decSeparators string) StringToDec func (conv StringToDecimalConverter) Convert(src string) (any, error) { src = replaceCharacters(src, conv.ignoreChars, "") src = replaceCharacters(src, conv.decSeparators, ".") - return decimal.NewDecimalFromString(src) + return decimal.MakeDecimalFromString(src) } // StringToUUIDConverter is a converter from string to UUID. @@ -206,7 +206,7 @@ func (StringToDatetimeConverter) Convert(src string) (any, error) { } _, offset := tm.Zone() tm = tm.In(time.FixedZone(datetime.NoTimezone, offset)) - return datetime.NewDatetime(tm) + return datetime.MakeDatetime(tm) } loc, err := time.LoadLocation(tzName) if err != nil { @@ -216,7 +216,7 @@ func (StringToDatetimeConverter) Convert(src string) (any, error) { if err != nil { return nil, err } - return datetime.NewDatetime(tm) + return datetime.MakeDatetime(tm) } // StringToMapConverter is a converter from string to map. @@ -343,7 +343,7 @@ func MakeDatetimeToStringConverter() DatetimeToStringConverter { // Convert is the implementation of Converter[*datetime.Datetime, string] // for DatetimeToStringConverter. -func (DatetimeToStringConverter) Convert(datetime *datetime.Datetime) (string, error) { +func (DatetimeToStringConverter) Convert(datetime datetime.Datetime) (string, error) { tm := datetime.ToTime() zone := tm.Location().String() if zone != "" { diff --git a/converter_test.go b/converter_test.go index 27bacc5..4fe95ab 100644 --- a/converter_test.go +++ b/converter_test.go @@ -10,8 +10,8 @@ import ( dec "github.com/shopspring/decimal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tarantool/go-tarantool/datetime" - "github.com/tarantool/go-tarantool/decimal" + "github.com/tarantool/go-tarantool/v2/datetime" + "github.com/tarantool/go-tarantool/v2/decimal" "github.com/tarantool/go-tupleconv" ) @@ -38,8 +38,8 @@ func HelperTestConverter[S any, T any]( } } -func getDatetimeWithValidate(t *testing.T, tm time.Time) *datetime.Datetime { - dt, err := datetime.NewDatetime(tm) +func getDatetimeWithValidate(t *testing.T, tm time.Time) datetime.Datetime { + dt, err := datetime.MakeDatetime(tm) require.NoError(t, err) return dt } @@ -247,35 +247,35 @@ func TestConverters(t *testing.T) { tupleconv.MakeStringToDecimalConverter(thSeparators, decSeparators): { { value: "0", - expected: &decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(0), 0)}, + expected: decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(0), 0)}, }, { value: "1", - expected: &decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(1), 0)}, + expected: decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(1), 0)}, }, { value: "-1", - expected: &decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(-1), 0)}, + expected: decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(-1), 0)}, }, { value: "43904329", - expected: &decimal.Decimal{ + expected: decimal.Decimal{ Decimal: dec.NewFromBigInt(big.NewInt(43904329), 0), }, }, { value: "-9223372036854775808", - expected: &decimal.Decimal{ + expected: decimal.Decimal{ Decimal: dec.NewFromBigInt(big.NewInt(int64(-9223372036854775808)), 0), }, }, { value: "1.447e+44", - expected: &decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(1447), 41)}, + expected: decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(1447), 41)}, }, { value: "1*5", - expected: &decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(15), -1)}, + expected: decimal.Decimal{Decimal: dec.NewFromBigInt(big.NewInt(15), -1)}, }, // Error. @@ -320,7 +320,7 @@ func TestMakeDatetimeToStringConverter(t *testing.T) { parisLoc) time3 := time.Date(2020, 9, 14, 12, 12, 12, 0, time.UTC) - cases := []convCase[*datetime.Datetime, string]{ + cases := []convCase[datetime.Datetime, string]{ { value: getDatetimeWithValidate(t, time1), expected: "2023-08-30T12:06:05.123456789+0400", @@ -335,7 +335,7 @@ func TestMakeDatetimeToStringConverter(t *testing.T) { }, } converter := tupleconv.MakeDatetimeToStringConverter() - HelperTestConverter[*datetime.Datetime, string](t, converter, cases) + HelperTestConverter[datetime.Datetime, string](t, converter, cases) } func TestMakeIntervalToStringConverter(t *testing.T) { diff --git a/example_test.go b/example_test.go index 0da1b44..342ae46 100644 --- a/example_test.go +++ b/example_test.go @@ -3,15 +3,15 @@ package tupleconv_test import ( "errors" "fmt" - "github.com/tarantool/go-tarantool" - "github.com/tarantool/go-tarantool/datetime" - "github.com/tarantool/go-tarantool/test_helpers" + "github.com/tarantool/go-tarantool/v2" + "github.com/tarantool/go-tarantool/v2/datetime" + "github.com/tarantool/go-tarantool/v2/test_helpers" "github.com/tarantool/go-tupleconv" "strconv" "strings" "time" - _ "github.com/tarantool/go-tarantool/uuid" + _ "github.com/tarantool/go-tarantool/v2/uuid" ) type filterIntConverter struct { @@ -207,7 +207,7 @@ func makeTtEncoder() func(any) (string, error) { return func(src any) (string, error) { switch src := src.(type) { case datetime.Datetime: - return datetimeConverter.Convert(&src) + return datetimeConverter.Convert(src) default: return fmt.Sprint(src), nil } diff --git a/go.mod b/go.mod index b1ac039..7217592 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/google/uuid v1.3.0 github.com/shopspring/decimal v1.3.1 github.com/stretchr/testify v1.7.1 - github.com/tarantool/go-tarantool v1.11.0 + github.com/tarantool/go-tarantool/v2 v2.0.0-20230823074441-d8df65dcd0f2 ) require ( @@ -15,7 +15,8 @@ require ( github.com/mattn/go-pointer v0.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect - github.com/tarantool/go-openssl v0.0.8-0.20230307065445-720eeb389195 // indirect + github.com/tarantool/go-iproto v0.1.0 // indirect + github.com/tarantool/go-openssl v0.0.8-0.20230801114713-b452431f934a // indirect github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect diff --git a/go.sum b/go.sum index 0ddb50a..60f57ff 100644 --- a/go.sum +++ b/go.sum @@ -21,10 +21,16 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tarantool/go-iproto v0.1.0 h1:zHN9AA8LDawT+JBD0/Nxgr/bIsWkkpDzpcMuaNPSIAQ= +github.com/tarantool/go-iproto v0.1.0/go.mod h1:LNCtdyZxojUed8SbOiYHoc3v9NvaZTB7p96hUySMlIo= github.com/tarantool/go-openssl v0.0.8-0.20230307065445-720eeb389195 h1:/AN3eUPsTlvF6W+Ng/8ZjnSU6o7L0H4Wb9GMks6RkzU= github.com/tarantool/go-openssl v0.0.8-0.20230307065445-720eeb389195/go.mod h1:M7H4xYSbzqpW/ZRBMyH0eyqQBsnhAMfsYk5mv0yid7A= +github.com/tarantool/go-openssl v0.0.8-0.20230801114713-b452431f934a h1:eeElglRXJ3xWKkHmDbeXrQWlZyQ4t3Ca1YlZsrfdXFU= +github.com/tarantool/go-openssl v0.0.8-0.20230801114713-b452431f934a/go.mod h1:M7H4xYSbzqpW/ZRBMyH0eyqQBsnhAMfsYk5mv0yid7A= github.com/tarantool/go-tarantool v1.11.0 h1:iLw8kYDQNFA3c3VHhBJJajXKUJPaz0StY/CdrutDn6s= github.com/tarantool/go-tarantool v1.11.0/go.mod h1:QRiXv0jnxwgxHtr9ZmifSr/eRba76gTUBgp69pDMX1U= +github.com/tarantool/go-tarantool/v2 v2.0.0-20230823074441-d8df65dcd0f2 h1:twlq30ASdD2pykY6GUht00Po//UaZ9f1UCHWWnlJlaQ= +github.com/tarantool/go-tarantool/v2 v2.0.0-20230823074441-d8df65dcd0f2/go.mod h1:wxReV/1H1dOTV47NebCEEbjTiqzRdGnQwEomU9YcwDo= github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= diff --git a/tt_test.go b/tt_test.go index 00bf03a..8808c0e 100644 --- a/tt_test.go +++ b/tt_test.go @@ -6,8 +6,8 @@ import ( dec "github.com/shopspring/decimal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tarantool/go-tarantool/datetime" - "github.com/tarantool/go-tarantool/decimal" + "github.com/tarantool/go-tarantool/v2/datetime" + "github.com/tarantool/go-tarantool/v2/decimal" "github.com/tarantool/go-tupleconv" "math/big" "testing" @@ -328,19 +328,19 @@ func TestStringToTTConvFactory(t *testing.T) { tupleconv.TypeDecimal: { { value: "12`13`144", - expected: &decimal.Decimal{ + expected: decimal.Decimal{ Decimal: dec.NewFromBigInt(big.NewInt(1213144), 0), }, }, { value: "111`22e333", - expected: &decimal.Decimal{ + expected: decimal.Decimal{ Decimal: dec.NewFromBigInt(big.NewInt(11122), 333), }, }, { value: "11,12", - expected: &decimal.Decimal{ + expected: decimal.Decimal{ Decimal: dec.NewFromBigInt(big.NewInt(1112), -2), }, },