Skip to content

Commit

Permalink
Remove init.
Browse files Browse the repository at this point in the history
  • Loading branch information
ncruces committed Jul 25, 2024
1 parent 64b77f1 commit 8d450f8
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func init() {
// The [sqlite3.Conn] can be used to execute queries, register functions, etc.
// Any error returned closes the connection and is returned to [database/sql].
func Open(dataSourceName string, init func(*sqlite3.Conn) error) (*sql.DB, error) {
c, err := (&SQLite{Init: init}).OpenConnector(dataSourceName)
c, err := (&SQLite{init}).OpenConnector(dataSourceName)
if err != nil {
return nil, err
}
Expand All @@ -82,10 +82,7 @@ func Open(dataSourceName string, init func(*sqlite3.Conn) error) (*sql.DB, error

// SQLite implements [database/sql/driver.Driver].
type SQLite struct {
// Init function is called by the driver on new connections.
// The [sqlite3.Conn] can be used to execute queries, register functions, etc.
// Any error returned closes the connection and is returned to [database/sql].
Init func(*sqlite3.Conn) error
init func(*sqlite3.Conn) error
}

// Open implements [database/sql/driver.Driver].
Expand Down Expand Up @@ -176,18 +173,18 @@ func (n *connector) Connect(ctx context.Context) (_ driver.Conn, err error) {
defer c.Conn.SetInterrupt(old)

if !n.pragmas {
err = c.Conn.BusyTimeout(60 * time.Second)
err = c.Conn.BusyTimeout(time.Minute)
if err != nil {
return nil, err
}
}
if n.driver.Init != nil {
err = n.driver.Init(c.Conn)
if n.driver.init != nil {
err = n.driver.init(c.Conn)
if err != nil {
return nil, err
}
}
if n.pragmas || n.driver.Init != nil {
if n.pragmas || n.driver.init != nil {
s, _, err := c.Conn.Prepare(`PRAGMA query_only`)
if err != nil {
return nil, err
Expand Down Expand Up @@ -326,6 +323,8 @@ func (c *conn) ExecContext(ctx context.Context, query string, args []driver.Name
}

func (c *conn) CheckNamedValue(arg *driver.NamedValue) error {
// Fast path: short circuit argument verification.
// Arguments will be rejected by conn.ExecContext.
return nil
}

Expand Down

0 comments on commit 8d450f8

Please sign in to comment.