2
0

Add driver.ConnPrepareContext support to stdlib.Conn

This commit is contained in:
Jack Christensen
2017-05-19 14:31:01 -05:00
parent 936cb68866
commit f8d7602270
2 changed files with 58 additions and 1 deletions
+5 -1
View File
@@ -208,6 +208,10 @@ type Conn struct {
}
func (c *Conn) Prepare(query string) (driver.Stmt, error) {
return c.PrepareContext(context.Background(), query)
}
func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
if !c.conn.IsAlive() {
return nil, driver.ErrBadConn
}
@@ -215,7 +219,7 @@ func (c *Conn) Prepare(query string) (driver.Stmt, error) {
name := fmt.Sprintf("pgx_%d", c.psCount)
c.psCount++
ps, err := c.conn.Prepare(name, query)
ps, err := c.conn.PrepareExContext(ctx, name, query, nil)
if err != nil {
return nil, err
}