pg_conn 0.41.1 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pg_conn/version.rb +1 -1
  3. data/lib/pg_conn.rb +19 -17
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c3ec749b3c1c7937e8c4fb0869c9ae3ef20549585f5385b44b1bf1f59275f02
4
- data.tar.gz: cc620bc609a52ccf03d1976c8c13d5c37cb5d6de1d5edacb44b1a5fb3e334f98
3
+ metadata.gz: 8d9aafa29dec55b879562f1ee2925322ccbde2c829d1c23c0529d41c171210e4
4
+ data.tar.gz: de71188ab165e6c0d3b8d1d1e947e5ea9deb0615287da2467dfffa7ae048d910
5
5
  SHA512:
6
- metadata.gz: f58e940330fe87d38ece2ed98516b2e0ba21b5c14c6f3f561bd3339278176182bd5201e5529d3071a6318c02b8e6f5031a9be7b8b491af0e95ac299c09b8769f
7
- data.tar.gz: fa5b3de455427cf6885c2d2757121465e312280f17a22da665fef5d232baa2406b0a14b2babd8ae6ebe22f04bb1d8f4d029d3f93c79be9c58b6ea16d6f9029be
6
+ metadata.gz: 7852a85c9a0b0ec2d31429a800cc1362e0c42d9a143cff80dfc47f81c2cad4fa3517777e91143f2a4876148b641a252d888e9316f53642af8f341772bce2bf8f
7
+ data.tar.gz: faf876c344f385b50f6813249114df1cec630ce85313517abb3e8a5a521524d14746fd58bed085cfc098298d0514bfa1c5bf17fa84fce0cb06790376a50699d4
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.41.1"
2
+ VERSION = "0.42.0"
3
3
  end
data/lib/pg_conn.rb CHANGED
@@ -1068,16 +1068,6 @@ module PgConn
1068
1068
 
1069
1069
  # TODO: Move to TransactionMethods
1070
1070
 
1071
- def commit()
1072
- if transaction?
1073
- pop_transaction(fail: false)
1074
- else
1075
- pg_exec("commit")
1076
- end
1077
- end
1078
-
1079
- def rollback() raise Rollback end
1080
-
1081
1071
  # True if a transaction is in progress
1082
1072
  #
1083
1073
  # Note that this requires all transactions to be started using PgConn's
@@ -1113,6 +1103,7 @@ module PgConn
1113
1103
  end
1114
1104
  end
1115
1105
 
1106
+ # FIXME :exception is unused
1116
1107
  def pop_transaction(commit: true, fail: true, exception: true)
1117
1108
  if transaction?
1118
1109
  if savepoint = @savepoints.pop
@@ -1156,13 +1147,11 @@ module PgConn
1156
1147
 
1157
1148
  # Start a transaction. If called with a block, the block is executed within
1158
1149
  # a transaction that is auto-committed if the commit option is true (the
1159
- # default). #transaction returns the result of the block or nil if no block
1160
- # was given
1161
- #
1162
- # The transaction can be rolled back inside the block by raising a
1163
- # PgConn::Rollback exception in which case #transaction returns nil. Note
1164
- # that the transaction timestamp is set to the start of the first
1165
- # transaction even if transactions are nested
1150
+ # default). The transaction is rolled back automatically if :commit is
1151
+ # false or if a PgConn::Rollback is raised with the block. #transaction
1152
+ # returns the result of the block or nil if no block was given. Note that
1153
+ # the transaction timestamp is set to the start of the first transaction
1154
+ # even if transactions are nested
1166
1155
  #
1167
1156
  # FIXME: There is some strange problem in rspec where #insert handles
1168
1157
  # an exception correctly while #exec, #execute, and #transaction does not
@@ -1187,6 +1176,19 @@ module PgConn
1187
1176
  end
1188
1177
  end
1189
1178
 
1179
+ # The flow to global transactions is
1180
+ #
1181
+ # conn.transaction # Starts a transaction
1182
+ # ...
1183
+ # if ok
1184
+ # conn.commit
1185
+ # else
1186
+ # conn.rollback
1187
+ # end
1188
+ #
1189
+ def commit() pop_transaction(fail: false) end
1190
+ def rollback() pop_transaction(commit: false, fail: false) end
1191
+
1190
1192
  def dump(*query)
1191
1193
  records = self.records(*query)
1192
1194
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_conn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.41.1
4
+ version: 0.42.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen