Skip to content

Commit

Permalink
feat: add read only transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Oct 12, 2023
1 parent 4126131 commit 367f939
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crdbx/readonly.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package crdbx

import (
"github.com/gobuffalo/pop/v6"
"github.com/ory/x/dbal"
"github.com/ory/x/sqlcon"
)

// SetTransactionReadOnly sets the transaction to read only for CockroachDB.
func SetTransactionReadOnly(c *pop.Connection) error {
if c.Dialect.Name() != dbal.DriverCockroachDB {
// Only CockroachDB supports this.
return nil
}

return sqlcon.HandleError(c.RawQuery("SET TRANSACTION READ ONLY").Exec())
}

0 comments on commit 367f939

Please sign in to comment.