Skip to content

Commit

Permalink
doc: db - the pragma problem (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
nalgeon committed Jun 8, 2024
1 parent 6a6119f commit 5692cf5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/sqlx/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ func (d *DB[T]) applySettings(pragma map[string]string) error {
// (see [DataSource]), so we wouldn't need this function.
// But since the mattn driver does not support setting pragmas
// in the connection string, we also set them here.
//
// The correct way to set pragmas for the mattn driver is to
// use the connection hook (see cmd/redka/main.go on how to do this).
// But since we can't be sure the user does that, we also set them here.
//
// Unfortunately, setting pragmas using Exec only sets them for
// a single connection. It's not a problem for d.RW (which has only
// one connection), but it is for d.RO (which has multiple connections).
// Still, it's better than nothing.
//
// See https://github.com/nalgeon/redka/issues/28 for more details.
if len(pragma) == 0 {
return nil
}
Expand Down

0 comments on commit 5692cf5

Please sign in to comment.