Skip to content

Commit

Permalink
Fix null in structured types arrays regression (#1187)
Browse files Browse the repository at this point in the history
* Reverted option check changes

* Change option enabled to pass context by pointer

* Performance improvement

---------

Co-authored-by: Dawid Heyman <[email protected]>
  • Loading branch information
sfc-gh-astachowski and sfc-gh-dheyman-1 authored Jul 31, 2024
1 parent 666fabc commit 6942d9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
22 changes: 14 additions & 8 deletions structured_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -1150,25 +1150,31 @@ func (st *structuredType) fieldMetadataByFieldName(fieldName string) (fieldMetad
return fieldMetadata{}, errors.New("no metadata for field " + fieldName)
}

func optionEnabled(ctx context.Context, option contextKey) bool {
v := ctx.Value(option)
func structuredTypesEnabled(ctx context.Context) bool {
v := ctx.Value(enableStructuredTypes)
if v == nil {
return false
}
d, ok := v.(bool)
return ok && d
}

func structuredTypesEnabled(ctx context.Context) bool {
return optionEnabled(ctx, enableStructuredTypes)
}

func mapValuesNullableEnabled(ctx context.Context) bool {
return optionEnabled(ctx, mapValuesNullable)
v := ctx.Value(mapValuesNullable)
if v == nil {
return false
}
d, ok := v.(bool)
return ok && d
}

func arrayValuesNullableEnabled(ctx context.Context) bool {
return optionEnabled(ctx, arrayValuesNullable)
v := ctx.Value(arrayValuesNullable)
if v == nil {
return false
}
d, ok := v.(bool)
return ok && d
}

func getSfFieldName(field reflect.StructField) string {
Expand Down
1 change: 0 additions & 1 deletion structured_type_read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,6 @@ func TestArraysWithNullValues(t *testing.T) {
} else {
assertDeepEqualE(t, tc.actual, tc.expected)
}
fmt.Printf("%v", reflect.TypeOf(tc.actual))
})
}
})
Expand Down

0 comments on commit 6942d9e

Please sign in to comment.