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
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

Comments

@b-s-a
Copy link

@b-s-a 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
@gopherbot gopherbot added the Proposal label Oct 26, 2018
@bcmills
Copy link
Member

@bcmills bcmills commented Oct 26, 2018

@kardianos
Copy link
Contributor

@kardianos kardianos commented Oct 26, 2018

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

@kardianos kardianos closed this Oct 26, 2018
@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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.