Skip to content

Commit

Permalink
chore: update dependencies and replace exp package with cmp (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
i-sevostyanov authored May 25, 2024
1 parent ffd7e51 commit 83a120a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 46 deletions.
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ go 1.22
require (
github.com/golang/mock v1.6.0
github.com/olekukonko/tablewriter v0.0.5
github.com/stretchr/testify v1.8.2
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea
golang.org/x/sync v0.2.0
github.com/stretchr/testify v1.9.0
golang.org/x/sync v0.7.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
21 changes: 8 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4=
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -49,6 +45,5 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
20 changes: 4 additions & 16 deletions internal/sql/expr/comparison/compare.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package comparison

import (
"cmp"
"fmt"

"golang.org/x/exp/constraints"

"github.com/i-sevostyanov/NanoDB/internal/sql"
)

Expand Down Expand Up @@ -49,23 +48,12 @@ func compareBool(left, right sql.Value) (sql.CompareType, error) {
rvalue = 1
}

return compare[uint8](lvalue, rvalue)
return sql.CompareType(cmp.Compare(lvalue, rvalue)), nil
}

func compareOrdered[T constraints.Ordered](left, right sql.Value) (sql.CompareType, error) {
func compareOrdered[T cmp.Ordered](left, right sql.Value) (sql.CompareType, error) {
lvalue := left.Raw().(T)
rvalue := right.Raw().(T)

return compare[T](lvalue, rvalue)
}

func compare[T constraints.Ordered](left, right T) (sql.CompareType, error) {
switch {
case left < right:
return sql.Less, nil
case left > right:
return sql.Greater, nil
default:
return sql.Equal, nil
}
return sql.CompareType(cmp.Compare(lvalue, rvalue)), nil
}
5 changes: 2 additions & 3 deletions internal/sql/expr/comparison/greater_or_equal.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package comparison

import (
"cmp"
"fmt"

"golang.org/x/exp/constraints"

"github.com/i-sevostyanov/NanoDB/internal/sql"
"github.com/i-sevostyanov/NanoDB/internal/sql/datatype"
)
Expand Down Expand Up @@ -61,7 +60,7 @@ func greaterOrEqualBool(left, right sql.Value) sql.Value {
return datatype.NewBoolean(lvalue >= rvalue)
}

func greaterOrEqual[T constraints.Ordered](left, right sql.Value) sql.Value {
func greaterOrEqual[T cmp.Ordered](left, right sql.Value) sql.Value {
lvalue := left.Raw().(T)
rvalue := right.Raw().(T)

Expand Down
5 changes: 2 additions & 3 deletions internal/sql/expr/comparison/greater_than.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package comparison

import (
"cmp"
"fmt"

"golang.org/x/exp/constraints"

"github.com/i-sevostyanov/NanoDB/internal/sql"
"github.com/i-sevostyanov/NanoDB/internal/sql/datatype"
)
Expand Down Expand Up @@ -61,7 +60,7 @@ func greaterThanBool(left, right sql.Value) sql.Value {
return datatype.NewBoolean(lvalue > rvalue)
}

func greaterThan[T constraints.Ordered](left, right sql.Value) sql.Value {
func greaterThan[T cmp.Ordered](left, right sql.Value) sql.Value {
lvalue := left.Raw().(T)
rvalue := right.Raw().(T)

Expand Down
5 changes: 2 additions & 3 deletions internal/sql/expr/comparison/less_or_equal.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package comparison

import (
"cmp"
"fmt"

"golang.org/x/exp/constraints"

"github.com/i-sevostyanov/NanoDB/internal/sql"
"github.com/i-sevostyanov/NanoDB/internal/sql/datatype"
)
Expand Down Expand Up @@ -61,7 +60,7 @@ func lessOrEqualBool(left, right sql.Value) sql.Value {
return datatype.NewBoolean(lvalue <= rvalue)
}

func lessOrEqual[T constraints.Ordered](left, right sql.Value) sql.Value {
func lessOrEqual[T cmp.Ordered](left, right sql.Value) sql.Value {
lvalue := left.Raw().(T)
rvalue := right.Raw().(T)

Expand Down
5 changes: 2 additions & 3 deletions internal/sql/expr/comparison/less_than.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package comparison

import (
"cmp"
"fmt"

"golang.org/x/exp/constraints"

"github.com/i-sevostyanov/NanoDB/internal/sql"
"github.com/i-sevostyanov/NanoDB/internal/sql/datatype"
)
Expand Down Expand Up @@ -61,7 +60,7 @@ func lessThanBool(left, right sql.Value) sql.Value {
return datatype.NewBoolean(lvalue < rvalue)
}

func lessThan[T constraints.Ordered](left, right sql.Value) sql.Value {
func lessThan[T cmp.Ordered](left, right sql.Value) sql.Value {
lvalue := left.Raw().(T)
rvalue := right.Raw().(T)

Expand Down

0 comments on commit 83a120a

Please sign in to comment.