Skip to content

Commit

Permalink
Merge pull request #644 from upper/cockroachdb-default-port
Browse files Browse the repository at this point in the history
cockroachdb: set default port
  • Loading branch information
xiam authored Jan 3, 2022
2 parents cb6aebc + 92d217c commit 28dd6cd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions adapter/cockroachdb/connection_pgx.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ func (c ConnectionURL) String() (s string) {
if host == "" {
host = "127.0.0.1"
}
if port == "" {
port = "26257"
}
u = append(u, "host="+escaper.Replace(host))
u = append(u, "port="+escaper.Replace(port))
} else {
u = append(u, "host="+escaper.Replace(c.Host))
}
if port == "" {
port = "26257"
}
u = append(u, "port="+escaper.Replace(port))
}

if c.Socket != "" {
Expand Down
6 changes: 3 additions & 3 deletions adapter/cockroachdb/connection_pgx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ func TestConnectionURL(t *testing.T) {

// Adding a host.
c.Host = "localhost"
assert.Equal(t, "host=localhost sslmode=prefer statement_cache_capacity=0", c.String())
assert.Equal(t, "host=localhost port=26257 sslmode=prefer statement_cache_capacity=0", c.String())

// Adding a username.
c.User = "Anakin"
assert.Equal(t, `host=localhost sslmode=prefer statement_cache_capacity=0 user=Anakin`, c.String())
assert.Equal(t, `host=localhost port=26257 sslmode=prefer statement_cache_capacity=0 user=Anakin`, c.String())

// Adding a password with special characters.
c.Password = "Some Sort of ' Password"
assert.Equal(t, `host=localhost password=Some\ Sort\ of\ \'\ Password sslmode=prefer statement_cache_capacity=0 user=Anakin`, c.String())
assert.Equal(t, `host=localhost password=Some\ Sort\ of\ \'\ Password port=26257 sslmode=prefer statement_cache_capacity=0 user=Anakin`, c.String())

// Adding a port.
c.Host = "localhost:1234"
Expand Down
8 changes: 4 additions & 4 deletions adapter/cockroachdb/connection_pq.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ func (c ConnectionURL) String() (s string) {
if host == "" {
host = "127.0.0.1"
}
if port == "" {
port = "26257"
}
u = append(u, "host="+escaper.Replace(host))
u = append(u, "port="+escaper.Replace(port))
} else {
u = append(u, "host="+escaper.Replace(c.Host))
}
if port == "" {
port = "26257"
}
u = append(u, "port="+escaper.Replace(port))
}

if c.Socket != "" {
Expand Down
6 changes: 3 additions & 3 deletions adapter/cockroachdb/connection_pq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ func TestConnectionURL(t *testing.T) {

// Adding a host.
c.Host = "localhost"
assert.Equal(t, "host=localhost sslmode=prefer", c.String())
assert.Equal(t, "host=localhost port=26257 sslmode=prefer", c.String())

// Adding a username.
c.User = "Anakin"
assert.Equal(t, `host=localhost sslmode=prefer user=Anakin`, c.String())
assert.Equal(t, `host=localhost port=26257 sslmode=prefer user=Anakin`, c.String())

// Adding a password with special characters.
c.Password = "Some Sort of ' Password"
assert.Equal(t, `host=localhost password=Some\ Sort\ of\ \'\ Password sslmode=prefer user=Anakin`, c.String())
assert.Equal(t, `host=localhost password=Some\ Sort\ of\ \'\ Password port=26257 sslmode=prefer user=Anakin`, c.String())

// Adding a port.
c.Host = "localhost:1234"
Expand Down

0 comments on commit 28dd6cd

Please sign in to comment.