Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38ffbfb

Browse files
Addressed review comments
1 parent 3a5169a commit 38ffbfb

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

database/postgres/postgres.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ func (p *Postgres) runStatement(statement []byte) error {
241241
ctx, cancel = context.WithTimeout(ctx, p.config.StatementTimeout)
242242
defer cancel()
243243
}
244-
query := strings.TrimSpace(string(statement))
245-
if query == "" {
244+
query := string(statement)
245+
if strings.TrimSpace(query) == "" {
246246
return nil
247247
}
248248
if _, err := p.conn.ExecContext(ctx, query); err != nil {

database/postgres/postgres_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ var (
4242
}
4343
)
4444

45-
func pgConnectionString(host, port string) string {
46-
return fmt.Sprintf("postgres://postgres:%s@%s:%s/postgres?sslmode=disable", pgPassword, host, port)
45+
func pgConnectionString(host, port string, options ...string) string {
46+
options = append(options, "sslmode=disable")
47+
return fmt.Sprintf("postgres://postgres:%s@%s:%s/postgres?%s", pgPassword, host, port, strings.Join(options, "&"))
4748
}
4849

4950
func isReady(ctx context.Context, c dktest.ContainerInfo) bool {
@@ -162,7 +163,7 @@ func TestMultipleStatementsInMultiStatementMode(t *testing.T) {
162163
t.Fatal(err)
163164
}
164165

165-
addr := pgConnectionString(ip, port) + "&x-multi-statement=true"
166+
addr := pgConnectionString(ip, port, "x-multi-statement=true")
166167
p := &Postgres{}
167168
d, err := p.Open(addr)
168169
if err != nil {

0 commit comments

Comments
 (0)