Skip to content

Commit

Permalink
Merge pull request #376 from ClickHouse/fix/nullable-or
Browse files Browse the repository at this point in the history
fix(proto): fix Nullable.Or
  • Loading branch information
ernado authored Jan 29, 2024
2 parents 99f8fe7 + a245919 commit 64b3804
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion proto/col_nullable.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func Null[T any]() Nullable[T] {
func (n Nullable[T]) IsSet() bool { return n.Set }

func (n Nullable[T]) Or(v T) T {
if n.Set {
if !n.Set {
return v
}
return n.Value
Expand Down
5 changes: 5 additions & 0 deletions proto/col_nullable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
"github.com/ClickHouse/ch-go/internal/gold"
)

func TestNullable(t *testing.T) {
require.Equal(t, Null[string]().Or("foo"), "foo")
require.Equal(t, NewNullable("bar").Or("foo"), "bar")
}

func TestColNullable_EncodeColumn(t *testing.T) {
const rows = 10
data := new(ColStr).Nullable()
Expand Down

0 comments on commit 64b3804

Please sign in to comment.