Skip to content

Commit ce0da89

Browse files
committed
Fix #335.
1 parent 9bbbab7 commit ce0da89

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

driver/driver.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,8 @@ func (n *connector) Connect(ctx context.Context) (ret driver.Conn, err error) {
263263
return nil, err
264264
}
265265
defer s.Close()
266-
if s.Step() && s.ColumnBool(0) {
267-
c.readOnly = '1'
268-
} else {
269-
c.readOnly = '0'
266+
if s.Step() {
267+
c.readOnly = s.ColumnBool(0)
270268
}
271269
err = s.Close()
272270
if err != nil {
@@ -322,7 +320,7 @@ type conn struct {
322320
txReset string
323321
tmRead sqlite3.TimeFormat
324322
tmWrite sqlite3.TimeFormat
325-
readOnly byte
323+
readOnly bool
326324
}
327325

328326
var (
@@ -358,9 +356,9 @@ func (c *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, e
358356

359357
c.txReset = ``
360358
txBegin := `BEGIN ` + txLock
361-
if opts.ReadOnly {
359+
if opts.ReadOnly && !c.readOnly {
362360
txBegin += ` ; PRAGMA query_only=on`
363-
c.txReset = `; PRAGMA query_only=` + string(c.readOnly)
361+
c.txReset = `; PRAGMA query_only=off`
364362
}
365363

366364
if old := c.Conn.SetInterrupt(ctx); old != ctx {

0 commit comments

Comments
 (0)