pg_conn 0.4.0 → 0.4.3
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 +7 -0
- data/lib/pg_conn/version.rb +1 -1
- data/lib/pg_conn.rb +19 -13
- 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: 308fc149f0ee84be457ed10f26c2fcb7a8b5ddd21678301820173b067f6a5725
|
4
|
+
data.tar.gz: ea285e08ddc1a5728f7ae022ccd85df8e6312f15f8b8cf7cbdfbf61e1b584a9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8140b39f3c6930592312b6ac97f9c2a64eead993c37cf6b85caaaa83bcacc723a2a8b14381fcb422d34013290e905d1740b8a9974823fb25e6e3f7debb0c6d27
|
7
|
+
data.tar.gz: 52209c53fd85e21fa6baf2e966d39f75459974c0fd0d8a2086923944f7ad750e0c599d71764add2eb7c88b4ea471a5ee4ce194def68b1586a9e5e49b1a0b0f01
|
data/TODO
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
TODO
|
2
|
+
o Option to accept no records when using #value, #tuple, and #struct. The
|
3
|
+
alternative is to use the 'one-table' as base table in the query and then
|
4
|
+
left join the rest
|
5
|
+
o Implement search_path
|
6
|
+
o Proper implementation of call of functions and procedures: Functions should
|
7
|
+
be called through #value, #tuple etc. and procedures through #call.
|
8
|
+
Proceduer output parameters needs handling too
|
2
9
|
o Create an abstract PgConnBase and have PgStmts (writes statements to array)
|
3
10
|
and PgConn (sends statements to server) classes derived from it
|
4
11
|
o fix silent
|
data/lib/pg_conn/version.rb
CHANGED
data/lib/pg_conn.rb
CHANGED
@@ -438,32 +438,38 @@ module PgConn
|
|
438
438
|
# (like #value or #values), a tuple if the record has multiple columns
|
439
439
|
# (like #tuple), and an array of of tuples if the result contained more
|
440
440
|
# than one record with multiple columns (like #tuples)
|
441
|
-
|
441
|
+
#
|
442
|
+
def call(name, *args, proc: false) # :proc may interfere with hashes
|
442
443
|
args_sql = args.map { |arg| # TODO: Use pg's encoder
|
443
444
|
case arg
|
444
445
|
when NilClass; "null"
|
445
446
|
when String; "'#{arg}'"
|
446
447
|
when Integer; arg
|
447
448
|
when TrueClass, FalseClass; arg
|
448
|
-
when Array;
|
449
|
+
when Array; "Array['#{arg.join("', '")}']" # Quick and dirty # FIXME
|
449
450
|
when Hash; raise NotImplementedError
|
450
451
|
else
|
451
452
|
raise ArgumentError, "Unrecognized value: #{arg.inspect}"
|
452
453
|
end
|
453
454
|
}.join(", ")
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
455
|
+
if proc
|
456
|
+
pg_exec "call #{name}(#{args_sql})"
|
457
|
+
return nil
|
458
|
+
else
|
459
|
+
r = pg_exec "select * from #{name}(#{args_sql})"
|
460
|
+
if r.ntuples == 0
|
461
|
+
raise Error, "No records returned"
|
462
|
+
elsif r.ntuples == 1
|
463
|
+
if r.nfields == 1
|
464
|
+
r.values[0][0]
|
465
|
+
else
|
466
|
+
r.values[0]
|
467
|
+
end
|
468
|
+
elsif r.nfields == 1
|
469
|
+
r.column_values(0)
|
460
470
|
else
|
461
|
-
r
|
471
|
+
r&.values
|
462
472
|
end
|
463
|
-
elsif r.nfields == 1
|
464
|
-
r.column_values(0)
|
465
|
-
else
|
466
|
-
r&.values
|
467
473
|
end
|
468
474
|
end
|
469
475
|
|
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.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|