File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package sqlds
22
33import (
44 "context"
5+ "crypto/sha256"
56 "database/sql"
67 "encoding/json"
78 "errors"
@@ -41,7 +42,8 @@ func defaultKey(datasourceUID string) string {
4142}
4243
4344func keyWithConnectionArgs (datasourceUID string , connArgs json.RawMessage ) string {
44- return fmt .Sprintf ("%s-%s" , datasourceUID , string (connArgs ))
45+ connectionArgsHash := sha256 .Sum256 (connArgs )
46+ return fmt .Sprintf ("%s-%x" , datasourceUID , connectionArgsHash )
4547}
4648
4749type dbConnection struct {
Original file line number Diff line number Diff line change @@ -64,15 +64,15 @@ func Test_getDBConnectionFromQuery(t *testing.T) {
6464 desc : "it should return the cached connection for the given args" ,
6565 dsUID : "uid1" ,
6666 args : "foo" ,
67- expectedKey : "uid1-foo " ,
67+ expectedKey : "uid1-2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae " ,
6868 existingDB : db2 ,
6969 expectedDB : db2 ,
7070 },
7171 {
7272 desc : "it should create a new connection with the given args" ,
7373 dsUID : "uid1" ,
7474 args : "foo" ,
75- expectedKey : "uid1-foo " ,
75+ expectedKey : "uid1-2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae " ,
7676 expectedDB : db3 ,
7777 },
7878 }
You can’t perform that action at this time.
0 commit comments