Skip to content

Possible improvement for Scanner with sqlint flag #239

@ghost

Description

Right now, go-enum generates a massive switch statement when using string enums with the flag --sqlint. This is mostly because the switch checks for nil values and integer types other than int64. gocyclo reports a score of 25, which could be a problem for https://goreportcard.com that wants a minimum gocyclo score of 15.

However, the documentation for sql.Scanner states this:

// The src value will be of one of the following types:
//
//    int64
//    float64
//    bool
//    []byte
//    string
//    time.Time
//    nil - for NULL values
Scan(src any) error

I'm a bit confused as to why go-enum has to check for other types such as int and uint64. Is it necessary?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions