Skip to content

database/sql: document allowed Scan conversions #9157

@dadkins

Description

@dadkins
What does 'go version' print?

go version go1.3.3 darwin/amd64

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

http://play.golang.org/p/mk7wJKtz4H

What happened?

NullString.Scan didn't accept a time.Time value:

error: unsupported driver -> Scan pair: time.Time -> *string

What should have happened instead?

It should have converted the time.Time value into a string, just it does with any other
type that Scan accepts.

Please provide any additional information below.

The contract for Scanner says:

        // Scan assigns a value from a database driver.
        //
        // The src value will be of one of the following restricted
        // set of types:
        //
        //    int64
        //    float64
        //    bool
        //    []byte
        //    string
        //    time.Time
        //    nil - for NULL values
        //
        // An error should be returned if the value can not be stored
        // without loss of information.
        Scan(src interface{}) error

All of the other types work by formatting the values as strings. Given that time.Time
has a String() function, I would assume it would be handled as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions