Skip to content

udt: support pointers in auto UDT structs #213

@mmatczuk

Description

@mmatczuk

If there is a nil pointer in an automatic UDT struct code panics.

panic({0xeee920, 0x4000370b10})
        runtime/panic.go:1052 +0x2b4
reflect.flag.mustBeAssignableSlow(0x96)
        reflect/value.go:262 +0xac
reflect.flag.mustBeAssignable(...)
        reflect/value.go:249
reflect.Value.Set({0x121f280, 0x400083d6b8, 0x96}, {0x121f280, 0x4000656b58, 0x16})
        reflect/value.go:1899 +0x34
github.com/scylladb/go-reflectx.FieldByIndexes({0x11c5a80, 0x400083d680, 0x99}, {0x40006a89d8, 0x1, 0x1})
        github.com/scylladb/go-reflectx@v1.0.1/reflect.go:212 +0x15c
github.com/scylladb/go-reflectx.(*Mapper).FieldMap(0x40000a41e0, {0x11c5a80, 0x400083d680, 0x99})
        github.com/scylladb/go-reflectx@v1.0.1/reflect.go:125 +0x1a8
github.com/scylladb/gocqlx/v2.makeUDT(...)
        github.com/scylladb/gocqlx/v2@v2.6.1-0.20211220144210-2b885ac61b11/udt.go:35
github.com/scylladb/gocqlx/v2.udtWrapSlice(0x40000a41e0, 0x0, {0x40001b1700, 0x8, 0x8})
        github.com/scylladb/gocqlx/v2@v2.6.1-0.20211220144210-2b885ac61b11/udt.go:70 +0x158
github.com/scylladb/gocqlx/v2.(*Queryx).Bind(...)
        github.com/scylladb/gocqlx/v2@v2.6.1-0.20211220144210-2b885ac61b11/queryx.go:213
github.com/scylladb/gocqlx/v2.(*Queryx).BindStruct(0x40002e93c0, {0xffde20, 0x40001fcd00})
        github.com/scylladb/gocqlx/v2@v2.6.1-0.20211220144210-2b885ac61b11/queryx.go:128 +0x138

Gocqlx should support fields of pointer type, allocate memory and handle that gracefully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions