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

database/sql/driver: Bool, Int32, String, DefaultParameterConverter are exported, but unsetable #18415

Closed
tgulacsi opened this issue Dec 22, 2016 · 9 comments
Milestone

Comments

@tgulacsi
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.8beta2

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

I'm trying to customize the driver.Bool to have it convert from float64 values to bool, too.

What did you expect to see?

I wanted to set driver.Bool to another type, which implements ValueConverter, embeds the original driver.Bool, and thus extend the set of convertable types.

What did you see instead?

var Bool = boolType{} in driver/types.go, thus nobody can touch it, though it is extended!

Is this intended? Can you advice other ways to customize the type conversions?

@gopherbot
Copy link

CL https://golang.org/cl/34642 mentions this issue.

@kardianos
Copy link
Contributor

@tgulacsi Supporting more types (both in and out of queries) are something I'd like to see go into go1.9.

I'd really like to fix these issues. There should be some sane defaults, driver conversions, and user conversions. In this case, unlike the mailed CL, we can't modify the type, we might be able to introduce new types, but I want to have a master game plan first.

@tgulacsi
Copy link
Contributor Author

tgulacsi commented Jan 6, 2017

On https://golang.org/cl/34642 my first attempt was turned down, but my second Patch Set has not been vetted. Maybe after a -2 nobody sees the new Patch Set? Or do they, just I'm impatient?

@bradfitz
Copy link
Contributor

bradfitz commented Jan 6, 2017

This bug is marked Go 1.9, so it doesn't show up on our dashboard.

But I don't think we want to change this. It's intentional that the types are private, so they can't be changed.

If you want different behavior, you can add new behavior and functions elsewhere, but you shouldn't change global variables and affect existing people's programs.

@bradfitz
Copy link
Contributor

bradfitz commented Jan 6, 2017

Assigning to @kardianos to close or understand the root problem, repurposing this bug or filing new bug(s) as needed.

@tgulacsi
Copy link
Contributor Author

tgulacsi commented Jan 7, 2017

Thanks for the clarification, @bradfitz!
If those types are intentionally private, I'll abandon that CL.

@kardianos
Copy link
Contributor

@tgulacsi Would https://go-review.googlesource.com/c/38533/ fix this issue for you?

@tgulacsi
Copy link
Contributor Author

tgulacsi commented Mar 31, 2017 via email

echarlus added a commit to echarlus/go-crate that referenced this issue May 9, 2017
…erly handle type conversions, handle at least time.Time columns properly by using the column type provided by Crate within the query’s results. driver.DefaultParameterConverter override is scheduled for GO 1.9 (see golang/go#18415)
@kardianos
Copy link
Contributor

The above CL has been merged in. I think this issue is now resolved in go1.9.

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

No branches or pull requests

5 participants