pgtk 0.4.0 → 0.5.0

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: 1e022a597acf397e44458f241077015a8edaec759737e95eac06b1df212cf83c
4
- data.tar.gz: '08bf19ebbebcb8c2daf355ce58675e04512346fa9addd21c9c82413a522cb363'
3
+ metadata.gz: d9b886c68a58dedba95aa0c86bf94d544532ea8652c65beb93bb852c4d9f06eb
4
+ data.tar.gz: 60727fc4ddc2050fdeec8a8a4aa638dc9695635724f0e28f55306b9d86ea7b43
5
5
  SHA512:
6
- metadata.gz: ef7e9fe5a549bb9cba6e4c3bea09c8c10fa6ff848141e9c1891bb9e12d2459c430c1132dd0e1bc3d27552319ebb11f12b86d6d2959654243651930c99298938a
7
- data.tar.gz: b2b3835cc8b61bd81729090eac1391fa6a6dffc43c721e9f3d13d2b545eeb228ba586811eb0ff345011560fb33647ef76073f8c1ab8b76fb840d9dc50ee7088f
6
+ metadata.gz: 439d320d935e09c0b3f554dce0ae44c576a9d966b51afd02c90770d4ec5ff4a29b05eebde0ba3716dbd1ac3168513d4aa17d22236994765ee11eb5066b8f0791
7
+ data.tar.gz: f604f0b90ad7628ef216467d0cc3a25b694713aca8b4e000202d88882980e3d9a741bc3819da98b38a9aaad5d541e442a6dc8eb69b870e51ba46e5ff14938550
data/lib/pgtk/pool.rb CHANGED
@@ -106,6 +106,17 @@ class Pgtk::Pool
106
106
  # end
107
107
  # end
108
108
  #
109
+ # When the query is too long it's convenient to use an array to specify it:
110
+ #
111
+ # pool.exec(
112
+ # [
113
+ # 'SELECT * FROM book',
114
+ # 'LEFT JOIN user ON user.id = book.owner',
115
+ # 'WHERE user.login = $1 AND book.title = $2'
116
+ # ],
117
+ # ['yegor256', 'Elegant Objects']
118
+ # )
119
+ #
109
120
  # More details about +exec_params+, which is called here, you can find
110
121
  # here: https://www.rubydoc.info/gems/pg/0.17.1/PG%2FConnection:exec_params
111
122
  def exec(query, args = [], result = 0)
@@ -145,7 +156,8 @@ class Pgtk::Pool
145
156
 
146
157
  def exec(query, args = [], result = 0)
147
158
  start = Time.now
148
- out = @conn.exec_params(query, args, result) do |res|
159
+ sql = query.is_a?(Array) ? query.join(' ') : query
160
+ out = @conn.exec_params(sql, args, result) do |res|
149
161
  if block_given?
150
162
  yield res
151
163
  else
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.4.0'
31
+ VERSION = '0.5.0'
32
32
  end
data/test/test_pool.rb CHANGED
@@ -48,7 +48,10 @@ class TestPool < Minitest::Test
48
48
  id = pool.transaction do |t|
49
49
  t.exec('DELETE FROM book')
50
50
  t.exec(
51
- 'INSERT INTO book (title) VALUES ($1) RETURNING id',
51
+ [
52
+ 'INSERT INTO book (title)',
53
+ 'VALUES ($1) RETURNING id'
54
+ ],
52
55
  ['Object Thinking']
53
56
  )[0]['id'].to_i
54
57
  end
@@ -81,7 +84,8 @@ class TestPool < Minitest::Test
81
84
  port: yaml['pgsql']['port'],
82
85
  dbname: yaml['pgsql']['dbname'],
83
86
  user: yaml['pgsql']['user'],
84
- password: yaml['pgsql']['password']
87
+ password: yaml['pgsql']['password'],
88
+ log: nil
85
89
  )
86
90
  pool.start(1)
87
91
  yield pool
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.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko