Allow setting readonly mode in bookmarks (#707)
This commit is contained in:
@@ -20,6 +20,7 @@ type Bookmark struct {
|
||||
Database string // Database name
|
||||
SSLMode string // Connection SSL mode
|
||||
SSH *shared.SSHInfo // SSH tunnel config
|
||||
ReadOnly bool // Enable read-only transaction mode
|
||||
}
|
||||
|
||||
// SSHInfoIsEmpty returns true if ssh configuration is not provided
|
||||
@@ -40,12 +41,13 @@ func (b Bookmark) ConvertToOptions() command.Options {
|
||||
}
|
||||
|
||||
return command.Options{
|
||||
URL: b.URL,
|
||||
Host: b.Host,
|
||||
Port: b.Port,
|
||||
User: user,
|
||||
Pass: pass,
|
||||
DbName: b.Database,
|
||||
SSLMode: b.SSLMode,
|
||||
URL: b.URL,
|
||||
Host: b.Host,
|
||||
Port: b.Port,
|
||||
User: user,
|
||||
Pass: pass,
|
||||
DbName: b.Database,
|
||||
SSLMode: b.SSLMode,
|
||||
ReadOnly: b.ReadOnly,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ func TestBookmarkWithVarsConvertToOptions(t *testing.T) {
|
||||
|
||||
t.Setenv("DB_USER", "user123")
|
||||
t.Setenv("DB_PASSWORD", "password123")
|
||||
|
||||
opt := b.ConvertToOptions()
|
||||
assert.Equal(t, expOpt, opt)
|
||||
})
|
||||
@@ -87,6 +88,7 @@ func TestBookmarkWithVarsConvertToOptions(t *testing.T) {
|
||||
|
||||
t.Setenv("DB_USER", "user123")
|
||||
t.Setenv("DB_PASSWORD", "password123")
|
||||
|
||||
opt := b.ConvertToOptions()
|
||||
assert.Equal(t, expOpt, opt)
|
||||
})
|
||||
@@ -101,16 +103,18 @@ func TestBookmarkConvertToOptions(t *testing.T) {
|
||||
Password: "password",
|
||||
Database: "mydatabase",
|
||||
SSLMode: "disable",
|
||||
ReadOnly: true,
|
||||
}
|
||||
|
||||
expOpt := command.Options{
|
||||
URL: "postgres://username:password@host:port/database?sslmode=disable",
|
||||
Host: "localhost",
|
||||
Port: 5432,
|
||||
User: "postgres",
|
||||
Pass: "password",
|
||||
DbName: "mydatabase",
|
||||
SSLMode: "disable",
|
||||
URL: "postgres://username:password@host:port/database?sslmode=disable",
|
||||
Host: "localhost",
|
||||
Port: 5432,
|
||||
User: "postgres",
|
||||
Pass: "password",
|
||||
DbName: "mydatabase",
|
||||
SSLMode: "disable",
|
||||
ReadOnly: true,
|
||||
}
|
||||
|
||||
opt := b.ConvertToOptions()
|
||||
|
||||
Reference in New Issue
Block a user