Skip to content

Fixed go incompatibility with pre-1.21 go version #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/).

## 1.4.6 - 2024-08-12

### Fixed
- Fixed go incompatibility with pre-1.21 go version, stemming from 1.4.4 and 1.4.5 releases.

## 1.4.5 - 2024-08-12

### Fixed
Expand Down
10 changes: 6 additions & 4 deletions nosqldb/internal/proto/binary/struct_decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (sr *structDecoder) decodeMap(m map[string]interface{}, v reflect.Value) er
if !mapElem.IsValid() {
mapElem = reflect.New(elemType).Elem()
} else {
mapElem.SetZero()
mapElem.Set(reflect.Zero(elemType))
}
subv = mapElem
} else {
Expand Down Expand Up @@ -144,7 +144,9 @@ func (sr *structDecoder) decodeArray(a []types.FieldValue, v reflect.Value) erro

if v.Kind() == reflect.Slice {
if size >= v.Cap() {
v.Grow(size - v.Cap())
newv := reflect.MakeSlice(v.Type(), v.Len(), size)
reflect.Copy(newv, v)
v.Set(newv)
}
if size > v.Len() {
v.SetLen(size)
Expand Down Expand Up @@ -174,13 +176,13 @@ func (sr *structDecoder) decodeFieldValue(mv any, v reflect.Value) error {
// Handle nil values differently
if mv == nil {
v = indirect(v, true)
v.SetZero()
v.Set(reflect.Zero(v.Type()))
return nil
}
switch mv.(type) {
case *types.EmptyValue, *types.NullValue, *types.JSONNullValue:
v = indirect(v, true)
v.SetZero()
v.Set(reflect.Zero(v.Type()))
return nil
}

Expand Down
12 changes: 7 additions & 5 deletions nosqldb/internal/proto/binary/struct_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (sr *StructReader) ReadMap(v reflect.Value) error {
if !mapElem.IsValid() {
mapElem = reflect.New(elemType).Elem()
} else {
mapElem.SetZero()
mapElem.Set(reflect.Zero(elemType))
}
subv = mapElem
} else {
Expand Down Expand Up @@ -226,7 +226,9 @@ func (sr *StructReader) ReadArray(v reflect.Value) error {

if v.Kind() == reflect.Slice {
if size >= v.Cap() {
v.Grow(size - v.Cap())
newv := reflect.MakeSlice(v.Type(), v.Len(), size)
reflect.Copy(newv, v)
v.Set(newv)
}
if size > v.Len() {
v.SetLen(size)
Expand Down Expand Up @@ -280,10 +282,10 @@ func (sr *StructReader) ReadFieldValue(v reflect.Value) error {
return nil
}
v = indirect(v, true)
v.SetZero()
v.Set(reflect.Zero(v.Type()))
//switch v.Kind() {
//case reflect.Interface, reflect.Pointer, reflect.Map, reflect.Slice:
//v.SetZero()
//v.Set(reflect.Zero(v.Type()))
// otherwise, ignore null for primitives/string (same as json library)
//}
return nil
Expand Down Expand Up @@ -373,7 +375,7 @@ func (sr *StructReader) ReadFieldValue(v reflect.Value) error {
return nil
}
if s == nil {
v.SetZero()
v.Set(reflect.Zero(v.Type()))
} else {
if v.Type().Kind() == reflect.Interface {
v.Set(reflect.ValueOf(s))
Expand Down