Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
b-s-a opened this issue Oct 26, 2018 · 2 comments · May be fixed by #57066
Closed

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

b-s-a opened this issue Oct 26, 2018 · 2 comments · May be fixed by #57066

Comments

@b-s-a
Copy link

b-s-a commented Oct 26, 2018

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
@gopherbot gopherbot added this to the Proposal milestone Oct 26, 2018
@bcmills
Copy link
Contributor

bcmills commented Oct 26, 2018

CC @bradfitz @kardianos @kevinburke

@kardianos
Copy link
Contributor

That would break existing programs. V2 will allow something like that.

@golang golang locked and limited conversation to collaborators Oct 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants