Skip to content

Commit d30ab5e

Browse files
authored
fix: skip Configurator func when marshalling to json (#411)
Do not include the Configurator func when marshalling a ConnectorConfig to json.
1 parent 4a72f5c commit d30ab5e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ type ConnectorConfig struct {
250250
// that will be used to create connections by the driver.Connector. Use this
251251
// function to set any further advanced configuration options that cannot be set
252252
// with a standard key/value pair in the Params map.
253-
Configurator func(config *spanner.ClientConfig, opts *[]option.ClientOption)
253+
Configurator func(config *spanner.ClientConfig, opts *[]option.ClientOption) `json:"-"`
254254
}
255255

256256
func (cc *ConnectorConfig) String() string {

driver_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"context"
1919
"database/sql"
2020
"database/sql/driver"
21+
"encoding/json"
2122
"fmt"
2223
"net"
2324
"reflect"
@@ -745,6 +746,13 @@ func TestConn_CheckNamedValue(t *testing.T) {
745746
}
746747
}
747748

749+
func TestConnectorConfigJson(t *testing.T) {
750+
_, err := json.Marshal(ConnectorConfig{})
751+
if err != nil {
752+
t.Fatalf("failed to marshal ConnectorConfig: %v", err)
753+
}
754+
}
755+
748756
// ValuerPerson implements driver.Valuer
749757
type ValuerPerson struct {
750758
Name string

0 commit comments

Comments
 (0)