Skip to content

QueryContext panic when the scanned value is nil and the destination is a slice of primitive #91

@mlaflamm

Description

@mlaflamm

I have a custom model that look like this:

var dest struct {
  Count int `sql:"primary_key"`
  ID    []string
}

When the id column is null like this, QueryContext panic with an error call of reflect.Value.Type on zero Value

count|id|
-----+--+
    0|  |

I’ve tracked the issue in the function scanContext.rowElemValuePtr of file qrm/scan_context.go. “ID” is a slice of primitive and since the value is nil, there is not enough type information to create the slice by reflection.

I am working on a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions