pgtk 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59a94cc2db34605f428b7f7828f2a4a1e2cec16cd0ed59903ed5cc2244fb2a07
4
- data.tar.gz: 96aae151d530dea967c1d1cff85a3192399d31bcf932305aca789e649cfe1b36
3
+ metadata.gz: eaf408030fd27aadb70b3b60c9905bacd625edc61a40fefac693c6ff5f009b79
4
+ data.tar.gz: 7a39f9206dbe25972f513a1585be2501d4316c8ad4ac41a5f066a303001f012c
5
5
  SHA512:
6
- metadata.gz: 03dafc5a8296523fbe2a47bf88e0f39f8ced19c39d638e432e21023d646ef988baa805544f37ab2dd82291bc2d0686c0b397b1c660cf0e565578356af25940ea
7
- data.tar.gz: 5d19a05b050ce1ba15b38405a05ddd61b29d80bef1f9fadbc3e7e5f371d3d6d0ac98b7a47d84a658208b98133218bcdd8f3f3b348f559dc7665c05058e8ce399
6
+ metadata.gz: b2547d36ec4b3911c2ff9c27583cff79bf66fab67932a00f3ae98f59c14914ed78638a3daed986c7ed64badc2288ce14a82ecb7326cb7b016e52b2376a89a626
7
+ data.tar.gz: 3dde21fee249a8714b7f3e8a6c18344457dbd0f601533e99beb8b1de903cc32321c1325b865d5cd11e0ef7b8fc6243551c000b25c6e52a22c60f1fb6154e815c
@@ -6,7 +6,7 @@ on:
6
6
  - master
7
7
  jobs:
8
8
  codecov:
9
- runs-on: ubuntu-20.04
9
+ runs-on: ubuntu-22.04
10
10
  steps:
11
11
  - uses: actions/checkout@v3
12
12
  - uses: actions/setup-ruby@v1
@@ -9,7 +9,7 @@ name: pdd
9
9
  - master
10
10
  jobs:
11
11
  pdd:
12
- runs-on: ubuntu-20.04
12
+ runs-on: ubuntu-22.04
13
13
  steps:
14
14
  - uses: actions/checkout@v3
15
15
  - uses: g4s8/pdd-action@master
@@ -9,7 +9,7 @@ name: xcop
9
9
  - master
10
10
  jobs:
11
11
  xcop:
12
- runs-on: ubuntu-20.04
12
+ runs-on: ubuntu-22.04
13
13
  steps:
14
14
  - uses: actions/checkout@v3
15
15
  - uses: g4s8/xcop-action@master
data/.rultor.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  docker:
2
- image: yegor256/rultor-image:1.19.0
2
+ image: yegor256/rultor-image:1.21.0
3
3
  assets:
4
4
  rubygems.yml: yegor256/home#assets/rubygems.yml
5
5
  install: |
data/lib/pgtk/pool.rb CHANGED
@@ -137,14 +137,19 @@ class Pgtk::Pool
137
137
  def exec(query, args = [], result = 0)
138
138
  start = Time.now
139
139
  sql = query.is_a?(Array) ? query.join(' ') : query
140
- out = @conn.exec_params(sql, args, result) do |res|
141
- if block_given?
142
- yield res
143
- else
144
- rows = []
145
- res.each { |r| rows << r }
146
- rows
140
+ begin
141
+ out = @conn.exec_params(sql, args, result) do |res|
142
+ if block_given?
143
+ yield res
144
+ else
145
+ rows = []
146
+ res.each { |r| rows << r }
147
+ rows
148
+ end
147
149
  end
150
+ rescue StandardError => e
151
+ @log.error("#{sql}: #{e.message}")
152
+ raise e
148
153
  end
149
154
  lag = Time.now - start
150
155
  if lag < 1
data/lib/pgtk/version.rb CHANGED
@@ -28,5 +28,5 @@ require_relative '../pgtk'
28
28
  # License:: MIT
29
29
  module Pgtk
30
30
  # Current version of the library.
31
- VERSION = '0.8.0'
31
+ VERSION = '0.8.1'
32
32
  end
data/test/test_pool.rb CHANGED
@@ -53,6 +53,27 @@ class TestPool < Minitest::Test
53
53
  end
54
54
  end
55
55
 
56
+ def test_logs_sql
57
+ log = Loog::Buffer.new
58
+ bootstrap(log: log) do |pool|
59
+ pool.exec(
60
+ 'INSERT INTO book (title) VALUES ($1)',
61
+ ['Object Thinking']
62
+ )
63
+ assert(log.to_s.include?('INSERT INTO book (title) VALUES ($1)'))
64
+ end
65
+ end
66
+
67
+ def test_logs_errors
68
+ log = Loog::Buffer.new
69
+ bootstrap(log: log) do |pool|
70
+ assert_raises PG::UndefinedTable do
71
+ pool.exec('INSERT INTO tableDoesNotExist (a) VALUES (42)')
72
+ end
73
+ assert(log.to_s.include?('INSERT INTO tableDoesNotExist'))
74
+ end
75
+ end
76
+
56
77
  def test_transaction
57
78
  bootstrap do |pool|
58
79
  id = pool.transaction do |t|
@@ -116,7 +137,7 @@ class TestPool < Minitest::Test
116
137
 
117
138
  private
118
139
 
119
- def bootstrap
140
+ def bootstrap(log: Loog::VERBOSE)
120
141
  Dir.mktmpdir 'test' do |dir|
121
142
  id = rand(100..999)
122
143
  Pgtk::PgsqlTask.new("pgsql#{id}") do |t|
@@ -136,7 +157,7 @@ class TestPool < Minitest::Test
136
157
  Rake::Task["liquibase#{id}"].invoke
137
158
  pool = Pgtk::Pool.new(
138
159
  Pgtk::Wire::Yaml.new(File.join(dir, 'cfg.yml')),
139
- log: Loog::VERBOSE
160
+ log: log
140
161
  )
141
162
  pool.start(1)
142
163
  yield pool
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgtk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-02 00:00:00.000000000 Z
11
+ date: 2023-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace