pgtk 0.17.0 → 0.17.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a1ac7d09cdc700a6fa51f239d1f14564f14f9cee56773a933e7e7d310291b1a
4
- data.tar.gz: 8bcce91182b85e2a592cd3031048b9687b56c7be0587eda199b1c97df944f630
3
+ metadata.gz: 72b30fd73fd65ec23cd7853399d575b696aef7db096b76e53d3448b881cbcf6c
4
+ data.tar.gz: 02f7a7c50eea3ce4b20862b6fcbb762e89de2259722dc034dd10c3a712345386
5
5
  SHA512:
6
- metadata.gz: '018f2c1cc65ca5b64f27609e4934f47163dcd8c4e582508e995dd332992b18f652de8fef63a9f5d86af969ce306796d2e2db0f490072933ab7a38cd91d02cfa0'
7
- data.tar.gz: 16c2631220d3cdad2aef2132213a79c922aae79edad0d34b9b7003bd5eec62977cbf9f3febb20a99b17612e77c074e64b7305078903b76e156e27bb90bfbb69c
6
+ metadata.gz: 30707ad9cf31b00a9fca53e8c83e1197d2e6f7c3bce07856fc0f93efa5240091f31e82f99cf91940c3466e499e4cf10f46b3bf16a4476a48256ab7b120fb3f84
7
+ data.tar.gz: 0adf7b70d2921a681af1f65cd6fbc77025a96a53d678ca25f50d1c7a6c7d6173240fcd8f4475eb16383dc4d5d92868420035d64744b5660a230cca57f304b54b
@@ -12,4 +12,4 @@ jobs:
12
12
  runs-on: ubuntu-24.04
13
13
  steps:
14
14
  - uses: actions/checkout@v4
15
- - uses: yegor256/copyrights-action@0.0.8
15
+ - uses: yegor256/copyrights-action@0.0.10
@@ -20,4 +20,4 @@ jobs:
20
20
  runs-on: ubuntu-24.04
21
21
  steps:
22
22
  - uses: actions/checkout@v4
23
- - uses: articulate/actions-markdownlint@v1
23
+ - uses: DavidAnson/markdownlint-cli2-action@v20.0.0
data/Gemfile.lock CHANGED
@@ -25,8 +25,8 @@ GEM
25
25
  elapsed (0.0.1)
26
26
  loog (> 0)
27
27
  tago (> 0)
28
- joined (0.2.0)
29
- json (2.12.0)
28
+ joined (0.3.0)
29
+ json (2.12.2)
30
30
  language_server-protocol (3.17.0.5)
31
31
  lint_roller (1.1.0)
32
32
  logger (1.7.0)
@@ -57,14 +57,14 @@ GEM
57
57
  loog (> 0)
58
58
  tago (> 0)
59
59
  racc (1.8.1)
60
- rack (3.1.14)
60
+ rack (3.1.15)
61
61
  rainbow (3.1.1)
62
62
  rake (13.2.1)
63
63
  random-port (0.7.5)
64
64
  tago (> 0)
65
65
  regexp_parser (2.10.0)
66
66
  rexml (3.4.1)
67
- rubocop (1.75.6)
67
+ rubocop (1.75.7)
68
68
  json (~> 2.3)
69
69
  language_server-protocol (~> 3.17.0.2)
70
70
  lint_roller (~> 1.1.0)
data/README.md CHANGED
@@ -44,14 +44,19 @@ Then, add this to your
44
44
  ```ruby
45
45
  require 'pgtk/pgsql_task'
46
46
  Pgtk::PgsqlTask.new :pgsql do |t|
47
- t.dir = 'target/pgsql' # Temp directory with PostgreSQL files
48
- t.fresh_start = true # To delete the directory on every start
47
+ # Temp directory with PostgreSQL files:
48
+ t.dir = 'target/pgsql'
49
+ # To delete the directory on every start;
50
+ t.fresh_start = true
49
51
  t.user = 'test'
50
52
  t.password = 'test'
51
53
  t.dbname = 'test'
52
- t.yaml = 'target/pgsql-config.yml' # YAML file to be created with connection details
53
- t.contexts = '!test' # list of contexts or empty if all
54
- t.config = { # list of PostgreSQL configuration options
54
+ # YAML file to be created with connection details:
55
+ t.yaml = 'target/pgsql-config.yml'
56
+ # List of contexts or empty if all:
57
+ t.contexts = '!test'
58
+ # List of PostgreSQL configuration options:
59
+ t.config = {
55
60
  log_min_messages: 'ERROR',
56
61
  log_filename: 'target/pg.log'
57
62
  }
@@ -66,11 +71,16 @@ are used inside):
66
71
  ```ruby
67
72
  require 'pgtk/liquibase_task'
68
73
  Pgtk::LiquibaseTask.new liquibase: :pgsql do |t|
69
- t.master = 'liquibase/master.xml' # Master XML file path
70
- t.yaml = ['target/pgsql-config.yml', 'config.yml'] # YAML files with connection details
71
- t.quiet = false # TRUE by default
72
- t.postgresql_version = '42.7.0' # overwriting default version
73
- t.liquibase_version = '3.2.2' # overwriting default version
74
+ # Master XML file path:
75
+ t.master = 'liquibase/master.xml'
76
+ # YAML files connection details:
77
+ t.yaml = ['target/pgsql-config.yml', 'config.yml']
78
+ # Reduce the amount of log messages (TRUE by default):
79
+ t.quiet = false
80
+ # Overwriting default version of PostgreSQL server:
81
+ t.postgresql_version = '42.7.0'
82
+ # Overwriting default version of Liquibase:
83
+ t.liquibase_version = '3.2.2'
74
84
  end
75
85
  ```
76
86
 
@@ -3,6 +3,7 @@
3
3
  # SPDX-FileCopyrightText: Copyright (c) 2019-2025 Yegor Bugayenko
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
+ require 'securerandom'
6
7
  require 'tago'
7
8
  require 'timeout'
8
9
  require_relative '../pgtk'
@@ -82,15 +83,17 @@ class Pgtk::Impatient
82
83
  def exec(sql, *args)
83
84
  return @pool.exec(sql, *args) if @off.any? { |re| re.match?(sql) }
84
85
  start = Time.now
86
+ token = SecureRandom.uuid
85
87
  begin
86
- Timeout.timeout(@timeout) do
88
+ Timeout.timeout(@timeout, Timeout::Error, token) do
87
89
  @pool.exec(sql, *args)
88
90
  end
89
- rescue Timeout::Error
91
+ rescue Timeout::Error => e
92
+ raise e unless e.message == token
90
93
  raise TooSlow, [
91
94
  'SQL query',
92
- ("with #{args.count} arguments" unless args.empty?),
93
- 'stopped after',
95
+ ("with #{args.count} argument#{'s' if args.count > 1}" unless args.empty?),
96
+ 'was terminated after',
94
97
  start.ago,
95
98
  'of waiting'
96
99
  ].compact.join(' ')
data/lib/pgtk/version.rb CHANGED
@@ -11,5 +11,5 @@ require_relative '../pgtk'
11
11
  # License:: MIT
12
12
  module Pgtk
13
13
  # Current version of the library.
14
- VERSION = '0.17.0'
14
+ VERSION = '0.17.1'
15
15
  end
data/resources/pom.xml CHANGED
@@ -11,7 +11,7 @@
11
11
  <packaging>pom</packaging>
12
12
  <properties>
13
13
  <postgresql.version>42.7.5</postgresql.version>
14
- <liquibase.version>4.31.1</liquibase.version>
14
+ <liquibase.version>4.32.0</liquibase.version>
15
15
  </properties>
16
16
  <dependencies>
17
17
  <dependency>
@@ -43,6 +43,18 @@ class TestImpatient < Pgtk::Test
43
43
  end
44
44
  end
45
45
 
46
+ def test_doesnt_shadow_larger_timeout
47
+ fake_pool do |pool|
48
+ assert_raises(Timeout::Error) do
49
+ Timeout.timeout(0.1) do
50
+ Pgtk::Impatient.new(pool, 999).exec(
51
+ 'SELECT COUNT(*) FROM generate_series(1, 100000000) AS a'
52
+ )
53
+ end
54
+ end
55
+ end
56
+ end
57
+
46
58
  def test_doesnt_interrupt
47
59
  fake_pool do |pool|
48
60
  id = Pgtk::Impatient.new(pool, 1).exec(
data/test/test_pool.rb CHANGED
@@ -38,6 +38,35 @@ class TestPool < Pgtk::Test
38
38
  end
39
39
  end
40
40
 
41
+ def test_logs_pgsql_errors_to_logger
42
+ buf = Loog::Buffer.new
43
+ fake_pool(log: buf) do |pool|
44
+ pool.exec(
45
+ "
46
+ CREATE FUNCTION intentional_failure() RETURNS trigger AS
47
+ 'BEGIN
48
+ IF NEW.title = ''War and War'' THEN
49
+ RAISE EXCEPTION ''The title of the book is bad'';
50
+ END IF;
51
+ RETURN NEW;
52
+ END' LANGUAGE PLPGSQL
53
+ "
54
+ )
55
+ pool.exec(
56
+ "
57
+ CREATE TRIGGER check_book_title
58
+ BEFORE INSERT ON book
59
+ FOR EACH ROW EXECUTE PROCEDURE intentional_failure();
60
+ "
61
+ )
62
+ assert_raises(PG::RaiseException) do
63
+ pool.exec('INSERT INTO book (title) VALUES ($1)', ['War and War'])
64
+ end
65
+ assert_includes(buf.to_s, 'The title of the book is bad')
66
+ assert_includes(buf.to_s, 'function intentional_failure() line 3')
67
+ end
68
+ end
69
+
41
70
  def test_queries_with_block
42
71
  fake_pool do |pool|
43
72
  pool.exec('INSERT INTO book (title) VALUES ($1)', ['1984'])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgtk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko