From 67642abfff798c25aade7f29c76654ab18e209c4 Mon Sep 17 00:00:00 2001 From: hykuan <33409123+hykuan@users.noreply.github.com> Date: Thu, 4 May 2023 19:29:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20numeric=20types=20in=20po?= =?UTF-8?q?inter=20embedded=20struct=20test=20failed=20(#6293)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- schema/field.go | 36 +++++++++++++++++++++++++++++++++++ tests/embedded_struct_test.go | 1 + 2 files changed, 37 insertions(+) diff --git a/schema/field.go b/schema/field.go index b5103d53..7d1a1789 100644 --- a/schema/field.go +++ b/schema/field.go @@ -604,6 +604,22 @@ func (field *Field) setupValuerAndSetter() { if data != nil && *data != nil { field.ReflectValueOf(ctx, value).SetInt(**data) } + case **int: + if data != nil && *data != nil { + field.ReflectValueOf(ctx, value).SetInt(int64(**data)) + } + case **int8: + if data != nil && *data != nil { + field.ReflectValueOf(ctx, value).SetInt(int64(**data)) + } + case **int16: + if data != nil && *data != nil { + field.ReflectValueOf(ctx, value).SetInt(int64(**data)) + } + case **int32: + if data != nil && *data != nil { + field.ReflectValueOf(ctx, value).SetInt(int64(**data)) + } case int64: field.ReflectValueOf(ctx, value).SetInt(data) case int: @@ -668,6 +684,22 @@ func (field *Field) setupValuerAndSetter() { if data != nil && *data != nil { field.ReflectValueOf(ctx, value).SetUint(**data) } + case **uint: + if data != nil && *data != nil { + field.ReflectValueOf(ctx, value).SetUint(uint64(**data)) + } + case **uint8: + if data != nil && *data != nil { + field.ReflectValueOf(ctx, value).SetUint(uint64(**data)) + } + case **uint16: + if data != nil && *data != nil { + field.ReflectValueOf(ctx, value).SetUint(uint64(**data)) + } + case **uint32: + if data != nil && *data != nil { + field.ReflectValueOf(ctx, value).SetUint(uint64(**data)) + } case uint64: field.ReflectValueOf(ctx, value).SetUint(data) case uint: @@ -720,6 +752,10 @@ func (field *Field) setupValuerAndSetter() { if data != nil && *data != nil { field.ReflectValueOf(ctx, value).SetFloat(**data) } + case **float32: + if data != nil && *data != nil { + field.ReflectValueOf(ctx, value).SetFloat(float64(**data)) + } case float64: field.ReflectValueOf(ctx, value).SetFloat(data) case float32: diff --git a/tests/embedded_struct_test.go b/tests/embedded_struct_test.go index 0d240fd8..3747dad9 100644 --- a/tests/embedded_struct_test.go +++ b/tests/embedded_struct_test.go @@ -107,6 +107,7 @@ func TestEmbeddedPointerTypeStruct(t *testing.T) { ID string Name string Email string + Age int } type HNPost struct {