Skip to content

proposal: database/sql: Return zero time.Time for nil values instead of error #28414

Closed
@b-s-a

Description

@b-s-a

Currently when you retrieving null timestamps from database result is error: unsupported Scan, storing driver.Value type into type *time.Time. This requires additional work for adding helper class NullTime with Scan() and Value() methods and then parsing them. But type time.Time has its own check for nil type: Time.IsZero(). It is need just add next code to src/database/sql/convert.go:301 to reduce extra work for users:

		case *time.Time:
			if d == nil {
				return errNilPtr
			}
			*d = time.Time{}
			return nil

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions