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 +4 -4
- data/.github/workflows/codecov.yml +1 -1
- data/.github/workflows/pdd.yml +1 -1
- data/.github/workflows/xcop.yml +1 -1
- data/.rultor.yml +1 -1
- data/lib/pgtk/pool.rb +12 -7
- data/lib/pgtk/version.rb +1 -1
- data/test/test_pool.rb +23 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaf408030fd27aadb70b3b60c9905bacd625edc61a40fefac693c6ff5f009b79
|
4
|
+
data.tar.gz: 7a39f9206dbe25972f513a1585be2501d4316c8ad4ac41a5f066a303001f012c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2547d36ec4b3911c2ff9c27583cff79bf66fab67932a00f3ae98f59c14914ed78638a3daed986c7ed64badc2288ce14a82ecb7326cb7b016e52b2376a89a626
|
7
|
+
data.tar.gz: 3dde21fee249a8714b7f3e8a6c18344457dbd0f601533e99beb8b1de903cc32321c1325b865d5cd11e0ef7b8fc6243551c000b25c6e52a22c60f1fb6154e815c
|
data/.github/workflows/pdd.yml
CHANGED
data/.github/workflows/xcop.yml
CHANGED
data/.rultor.yml
CHANGED
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
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
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
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:
|
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.
|
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-
|
11
|
+
date: 2023-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|