diff options
| author | Daniel Theophanes <kardianos@gmail.com> | 2017-11-14 08:53:56 -0800 |
|---|---|---|
| committer | Daniel Theophanes <kardianos@gmail.com> | 2017-11-16 22:36:07 +0000 |
| commit | b44b2feb914d866250f2efb744b24de0ce8c161a (patch) | |
| tree | 6820e8a597a5d2e51282ca3f490f92522995d665 /src/database/sql/fakedb_test.go | |
| parent | 096b195df5b6b29521af3e10ef40f4118164596b (diff) | |
| download | go-b44b2feb914d866250f2efb744b24de0ce8c161a.tar.xz | |
database/sql: allow OpenConnector in a driver.Driver interface
While driver.Connector was previously added to allow non-string
connection arguments and access to the context, most users of
the sql package will continue to rely on a string DSN.
Allow drivers to implement a string DSN to Connector interface
that both allows a single parsing of the string DSN and uses
the Connector interface which passes available context to
the driver dialer.
Fixes #22713
Change-Id: Ia0b862262f4c4670effe2538d0d6d43733fea18d
Reviewed-on: https://go-review.googlesource.com/77550
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/database/sql/fakedb_test.go')
| -rw-r--r-- | src/database/sql/fakedb_test.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/database/sql/fakedb_test.go b/src/database/sql/fakedb_test.go index 31e22a7a74..e795412de0 100644 --- a/src/database/sql/fakedb_test.go +++ b/src/database/sql/fakedb_test.go @@ -71,6 +71,16 @@ func (c *fakeConnector) Driver() driver.Driver { return fdriver } +type fakeDriverCtx struct { + fakeDriver +} + +var _ driver.DriverContext = &fakeDriverCtx{} + +func (cc *fakeDriverCtx) OpenConnector(name string) (driver.Connector, error) { + return &fakeConnector{name: name}, nil +} + type fakeDB struct { name string |
