• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

go-sql-driver / mysql / 5375233382

pending completion
5375233382

Pull #1454

github

Jille
Expose a MySQLConn interface for use with database/sql.Conn.Raw()

Based on the design of @methane

We can later add a LoadLocalInfile() method instead of the Register...()
functions.

for issue #1416
Pull Request #1454: Expose a MySQLConn interface for use with database/sql.Conn.Raw()

0 of 15 new or added lines in 1 file covered. (0.0%)

3028 of 3705 relevant lines covered (81.73%)

1387852.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/interface.go
1
package mysql
2

3
import (
4
        "context"
5
        "database/sql"
6
        "fmt"
7
        "time"
8
)
9

10
// MySQLConn exposes the usable methods on driverConn given to database/sql.Conn.Raw.
11
type MySQLConn interface {
12
        // Prevent other modules from implementing this interface so we can keep adding methods.
13
        isMySQLConn()
14

15
        // Location gets the Config.Loc of this connection. (This may differ from `time_zone` connection variable.)
16
        Location() *time.Location
17
}
18

NEW
19
func (mc *mysqlConn) isMySQLConn() {
×
NEW
20
}
×
21

NEW
22
func (mc *mysqlConn) Location() *time.Location {
×
NEW
23
        return mc.cfg.Loc
×
NEW
24
}
×
25

26
var _ MySQLConn = &mysqlConn{}
27

NEW
28
func ExampleMySQLConn() {
×
NEW
29
        db, _ := sql.Open("mysql", "root:pw@unix(/tmp/mysql.sock)/myDatabase?parseTime=true&loc=Europe%2FAmsterdam")
×
NEW
30
        conn, _ := db.Conn(context.Background())
×
NEW
31
        var location *time.Location
×
NEW
32
        conn.Raw(func(dc any) error {
×
NEW
33
                mc := dc.(MySQLConn)
×
NEW
34
                location = mc.Location()
×
NEW
35
                return nil
×
NEW
36
        })
×
NEW
37
        fmt.Println(location)
×
38
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc