pg_conn 0.23.0 → 0.24.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 (5) hide show
  1. checksums.yaml +4 -4
  2. data/TODO +18 -6
  3. data/lib/pg_conn/version.rb +1 -1
  4. data/lib/pg_conn.rb +14 -5
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7de75668042e3abdc5b983e0b9a3f6c909ff69aeed2f22c632d1c693f3baac0
4
- data.tar.gz: 90cecbdd79e6478d7f6bd1bc3ae042917bc2683771c89de61aab6c05fa2e5279
3
+ metadata.gz: 45c913cadea7c545637f0291133fd43f727beef5efe726377c406e720c105d7d
4
+ data.tar.gz: 25ed1737f4bba574d02c7d1e1d823957de723f86e2eeca94f9ea8ef6160c191e
5
5
  SHA512:
6
- metadata.gz: 76b775138260668bf75e5bc31e220561f665dffc901349a9ec875e7ec594dee2750e0d979bde80e9045e38e44a3894fe55c2be37faefbe7f35173812cea2a22a
7
- data.tar.gz: f0e2e9169cd734814cce4e8b73f7ec017cf3fd9a2622290c4acbf06620ddb3b943957ab5dab527ee0e29a9d71ad4efb511f4f219543ca86301d9fd5c4f5838ad
6
+ metadata.gz: 696866896b4bea3ebec5313398f580581627535ccf7fca01f94f6f7e9a6198ceff7173b81d21d3725d4d7f0ac7118428a0eab2a098d3f360913926c46d460eaf
7
+ data.tar.gz: de5d2541d1384bfa7721f7ec3274f1a232b97d9bc08791f6f5a3c5783b19d5a8d65ac25d7d37cea0e47e27fc4391dad4eb0f15f96584875e0ed526d98bb1a520
data/TODO CHANGED
@@ -1,4 +1,20 @@
1
1
  TODO
2
+
3
+ o Instrumentation of connection object
4
+
5
+ # Augment conn object exec method to emit duration of the query
6
+ conn.define_singleton_method(:original_exec, conn.method(:exec))
7
+ conn.define_singleton_method(:exec) do |*args|
8
+ t0 = Time.now
9
+ r = original_exec(*args)
10
+ t1 = Time.now
11
+ @duration = ((t1 - t0) * 1000).round()
12
+ r
13
+ end
14
+ conn.define_singleton_method(:duration) do
15
+ @duration
16
+ end
17
+
2
18
  o Use :elem_type everywhere
3
19
  o Use 'drop ... cascade' everywhere
4
20
  o db.context(schema: app_portal, transaction: true) { ... }
@@ -19,7 +35,6 @@ TODO
19
35
 
20
36
  server.call :sp_nic_update_comtext, str_id, str_comtext, site.current_user.id
21
37
 
22
-
23
38
  o Have a 'with' method that combines multiple brachet-methods:
24
39
 
25
40
  conn.with(schema: public, transation: true) { ... }
@@ -34,9 +49,8 @@ TODO
34
49
  struct # exists
35
50
  structs
36
51
 
37
-
38
52
  o Make rdbms, role, schema, and session methods part of a PgModel file that
39
- monkey patch PgConn objects to include a #model method that returns the
53
+ monkey patch PgConn objects to include a #model method that returns the
40
54
  top-level rdbms object
41
55
 
42
56
  o #group method
@@ -67,8 +81,6 @@ TODO
67
81
  end
68
82
  end
69
83
 
70
-
71
-
72
84
  o Use enumerators
73
85
  o Use SQL parameters. Optionally with a different syntax:
74
86
  $var - Value that gets single-quoted
@@ -93,7 +105,7 @@ TODO
93
105
  # grant(role, to_role)
94
106
  # grant(privilege, subject, to_role)
95
107
  def grant(role, to_role)
96
- #
108
+ #
97
109
  conn.exec "grant #{role} to #{to_role}"
98
110
  end
99
111
  o Allow a :type argument to all query methods that can be used to specify the
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.23.0"
2
+ VERSION = "0.24.0"
3
3
  end
data/lib/pg_conn.rb CHANGED
@@ -220,6 +220,13 @@ module PgConn
220
220
  @savepoints = nil # Stack of savepoint names. Nil if no transaction in progress
221
221
  end
222
222
 
223
+ # Reset connection but keep noise level (TODO: How about the other
224
+ # per-session settings in #initialize? Are they cleared by #reset too?)
225
+ def reset
226
+ @pg_connection.reset
227
+ @pg_connection.exec "set client_min_messages to warning;" # Silence warnings
228
+ end
229
+
223
230
  # Close the database connection. TODO: Rename 'close'
224
231
  def terminate()
225
232
  @pg_connection.close if @pg_connection && !@pg_connection.finished?
@@ -261,7 +268,7 @@ module PgConn
261
268
  # of values
262
269
  #
263
270
  # The :elem_type option can be a postgres type name (String or Symbol) or
264
- # an array of type names. They are used as the required explicit element
271
+ # an array of type names. It is used as the required explicit element
265
272
  # type when the argument is an empty array. The element types shoud be in
266
273
  # the same order as the array arguments. Nested arrays is not supported
267
274
  #
@@ -579,14 +586,16 @@ module PgConn
579
586
  h
580
587
  end
581
588
 
582
- # Return the value of calling the given function (which can be a String or
583
- # a Symbol and can contain the schema of the function). It dynamically
589
+ # Return the value of calling the given postgres function. It dynamically
584
590
  # detects the structure of the result and return a value or an array of
585
591
  # values if the result contained only one column (like #value or #values),
586
592
  # a tuple if the record has multiple columns (like #tuple), and an array of
587
593
  # of tuples if the result contained more than one record with multiple
588
- # columns (like #tuples). If the :proc option is true the "function" is
589
- # assumed to be a procedure
594
+ # columns (like #tuples).
595
+ #
596
+ # The name argument can be a String or a Symbol that may contain the schema
597
+ # of the function. If the :proc option is true the "function" is assumed
598
+ # to be a procedure
590
599
  #
591
600
  def call(name, *args, elem_type: nil, proc: false) # :proc may interfere with hashes
592
601
  args_seq = quote_values(args, elem_type: elem_type)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_conn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-24 00:00:00.000000000 Z
11
+ date: 2024-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg