em-pg-client-helper 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/em-pg-client-helper/transaction.rb +5 -1
- data/spec/db_transaction_spec.rb +12 -0
- metadata +3 -3
@@ -13,7 +13,11 @@ class PG::EM::Client::Helper::Transaction
|
|
13
13
|
@dg = dg
|
14
14
|
dg.add(
|
15
15
|
conn.exec_defer("BEGIN").callback do
|
16
|
-
|
16
|
+
begin
|
17
|
+
blk.call(self)
|
18
|
+
rescue StandardError => ex
|
19
|
+
rollback(ex)
|
20
|
+
end
|
17
21
|
end.errback { |ex| rollback(ex) }
|
18
22
|
)
|
19
23
|
end.callback { commit }.errback { |ex| rollback(ex) }
|
data/spec/db_transaction_spec.rb
CHANGED
@@ -142,4 +142,16 @@ describe "PG::EM::Client::Helper#db_transaction" do
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
end
|
145
|
+
|
146
|
+
it "catches exceptions" do
|
147
|
+
in_em do
|
148
|
+
expect_query("BEGIN")
|
149
|
+
expect_query('INSERT INTO "foo" ("bar") VALUES ($1)', ["baz"])
|
150
|
+
expect_query("ROLLBACK")
|
151
|
+
in_transaction do |txn|
|
152
|
+
txn.insert("foo", :bar => 'baz')
|
153
|
+
raise "OMFG"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
145
157
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-pg-client-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -238,7 +238,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
238
238
|
version: '0'
|
239
239
|
segments:
|
240
240
|
- 0
|
241
|
-
hash:
|
241
|
+
hash: -448126625621409328
|
242
242
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
243
|
none: false
|
244
244
|
requirements:
|
@@ -247,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
247
|
version: '0'
|
248
248
|
segments:
|
249
249
|
- 0
|
250
|
-
hash:
|
250
|
+
hash: -448126625621409328
|
251
251
|
requirements: []
|
252
252
|
rubyforge_project:
|
253
253
|
rubygems_version: 1.8.23
|