Skip to content

Commit dc94de0

Browse files
author
c9845 (AA)
committed
Define new config file field for more advanced connections to databases. This allows us to add extra configuration options to the connection strings.
Currently, this is only implemented for MS SQL Server and was used in development to allow connecting to the db server via an unencrypted connection ("encrypt=disable").
1 parent 34b7d67 commit dc94de0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sqldb.go

+13
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ type Config struct {
126126
User string
127127
Password string
128128

129+
//ConnectionOptions is a list of key-value pairs of options used when building
130+
//the connection string used to connect to a database. Each driver/database type
131+
//will handle these differently.
132+
ConnectionOptions map[string]string
133+
129134
//SQLitePath is the path where the SQLite database file is located.
130135
SQLitePath string
131136

@@ -432,6 +437,14 @@ func (cfg *Config) buildConnectionString(deployingDB bool) (connString string) {
432437

433438
q := url.Values{}
434439
q.Add("database", cfg.Name)
440+
441+
//Handle other connection options.
442+
if len(cfg.ConnectionOptions) > 0 {
443+
for key, value := range cfg.ConnectionOptions {
444+
q.Add(key, value)
445+
}
446+
}
447+
435448
u.RawQuery = q.Encode()
436449

437450
connString = u.String()

0 commit comments

Comments
 (0)