From 8ca3bb1316dbb48159a0c7d1910194f49ca4cee3 Mon Sep 17 00:00:00 2001 From: sfc-gh-jbahk <63611797+sfc-gh-jbahk@users.noreply.github.com> Date: Mon, 8 Nov 2021 18:08:51 -0500 Subject: [PATCH] SNOW-499317 Fix panic when disable telemetry enabled (#490) --- connection.go | 2 +- telemetry_test.go | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/connection.go b/connection.go index 82130b205..f06cabac7 100644 --- a/connection.go +++ b/connection.go @@ -661,7 +661,7 @@ func buildSnowflakeConn(ctx context.Context, config Config) (*snowflakeConn, err tokenAccessor = getSimpleTokenAccessor() } if sc.cfg.DisableTelemetry { - sc.telemetry.enabled = false + sc.telemetry = &snowflakeTelemetry{enabled: false} } // authenticate diff --git a/telemetry_test.go b/telemetry_test.go index e9846608a..533378c2c 100644 --- a/telemetry_test.go +++ b/telemetry_test.go @@ -86,3 +86,18 @@ func TestTelemetrySQLException(t *testing.T) { t.Errorf("there should be no telemetry data in log. found: %v", len(st.logs)) } } + +func TestDisableTelemetry(t *testing.T) { + config, _ := ParseDSN(dsn) + config.DisableTelemetry = true + sc, err := buildSnowflakeConn(context.Background(), *config) + if err != nil { + t.Fatal(err) + } + if err = authenticateWithConfig(sc); err != nil { + t.Fatal(err) + } + if _, err = sc.Query("select 1", nil); err != nil { + t.Fatal(err) + } +}