Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #935 from joyent/ether/v2-fix-ro-db
Browse files Browse the repository at this point in the history
v2: fix ro db
  • Loading branch information
karenetheridge authored Nov 6, 2019
2 parents 906b8d2 + 01d9c1e commit 159493f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
8 changes: 5 additions & 3 deletions lib/Conch/Plugin/Database.pm
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ See L</schema>; can be used interchangeably with it.
=head2 ro_schema
Provides (guaranteed) read-only access to the database via L<DBIx::Class>. Returns a
L<Conch::DB> object that persists for the lifetime of the application.
L<Conch::DB> object that persists for the lifetime of the request (B<not the application>).
Note that because of the use of C<< AutoCommit => 0 >>, database errors must be explicitly
cleared with C<< ->txn_rollback >>; see L<DBD::Pg/"ReadOnly-(boolean)">.
=cut

my $_ro_schema;
$app->helper(ro_schema => sub {
$app->helper(ro_schema => sub ($c) {
my $_ro_schema = $c->stash('ro_schema');
if ($_ro_schema) {
# clear the transaction of any errors, which accumulate because we have
# AutoCommit => 0 for this connection. Otherwise, we will get:
Expand All @@ -84,6 +84,8 @@ cleared with C<< ->txn_rollback >>; see L<DBD::Pg/"ReadOnly-(boolean)">.
AutoCommit => 0,
},
);
$c->stash('ro_schema', $_ro_schema);
return $_ro_schema;
});

=head2 db_<table>s, db_ro_<table>s
Expand Down
13 changes: 0 additions & 13 deletions t/git-docs.t

This file was deleted.

0 comments on commit 159493f

Please sign in to comment.