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: API #2842

Closed
rsc opened this issue Feb 2, 2012 · 4 comments
Closed

database/sql/driver: API #2842

rsc opened this issue Feb 2, 2012 · 4 comments
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Feb 2, 2012

The docs are a bit confusing.  A few suggested simplifications.

First, introduce type Value interface{} to represent (even if not
compiler-checked) the driver "subset" values (also avoid the
word subset).

// A driver Value is a value that drivers must be able to handle.
// A Value is either nil or an instance of one of these types:
//    int64
//    float64
//    ...
type Value interface{}
and use Value where that is what is meant.

// IsValue reports whether v is a driver Value.
func IsValue(v interface{}) bool
(old IsParameterSubsetType)

// IsScanValue reports whether v is an appropriate driver Value
// for use in Scan.  This is any driver Value except strings.
func IsScanValue(v interface{}) bool
(old IsScanSubsetType)

// Data can control how it is converted to Value by 
// implementing the Value method.
type Valuer interface {
    Value() (Value, error)
}
(old SubsetValuer)

The ValueConverter interface is not getting anything from
its receiver, and it introduces an extra level that is confusing.
Suggest making it a function

// A Converter converts any value into a driver Value.
type Converter func(interface{}) (Value, error)
(old ValueConverter)

Other issues:
"DDL" is mentioned in the docs but not defined (probably remove it, don't
define it).

Address the TODO in driver.Stmt's Close comment one way or another.
@bradfitz
Copy link
Contributor

Comment 1:

Owner changed to @bradfitz.

@bradfitz
Copy link
Contributor

Comment 2:

CL here:
http://golang.org/cl/5674084/
Not done:
-- Converter func:  the Null and NotNull types use the receiver.  Still thinking.
-- DDL:  Anybody writing a driver would know these I think, and find them convenient to
return?  Don't feel really strongly, though.

@rsc
Copy link
Contributor Author

rsc commented Feb 17, 2012

Comment 3:

I still have no idea what DDL stands for.  At least define it.

@bradfitz
Copy link
Contributor

Comment 4:

This issue was closed by revision 943f6cc.

Status changed to Fixed.

@rsc rsc added fixed labels Feb 20, 2012
@rsc rsc added this to the Go1 milestone Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

3 participants