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.
- checksums.yaml +4 -4
- data/TODO +18 -6
- data/lib/pg_conn/version.rb +1 -1
- data/lib/pg_conn.rb +14 -5
- 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: 45c913cadea7c545637f0291133fd43f727beef5efe726377c406e720c105d7d
|
4
|
+
data.tar.gz: 25ed1737f4bba574d02c7d1e1d823957de723f86e2eeca94f9ea8ef6160c191e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/pg_conn/version.rb
CHANGED
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.
|
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
|
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).
|
589
|
-
#
|
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.
|
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-
|
11
|
+
date: 2024-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|