pg_conn 0.4.0 → 0.4.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/TODO +7 -0
  3. data/lib/pg_conn/version.rb +1 -1
  4. data/lib/pg_conn.rb +18 -12
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c6b35126469d1a4c72a3ecdfe32502266eefce16574d91f0b00b9c969b586f8
4
- data.tar.gz: ad15bf23023dad7d1a41716c7d3587e0b27400c4fee41bb3870f692adef9e908
3
+ metadata.gz: e9c82eb8c1dc8b48877759c39ecd0f3f0d2a8bb5f37abfffd0969208c1718cd4
4
+ data.tar.gz: b003f7990a98a8a63e9bd847ffdb2b44d3de9b61067c37189a8267efd3872346
5
5
  SHA512:
6
- metadata.gz: b49f50d2ceb9b87e55d6ae9a076bc477db4e5df474fa291d1c9f03747bb919996b209ec2bf15680651d93b1900f9067690a5653d2e492834348d6c4996b8d2de
7
- data.tar.gz: 62ad8e07479117796196ff0cf8894a7d4562ab4d6f54eccf826830ba03df0d69897277fb307e7fb0e924e701b8bbe95ea5d81b9b5d0e964b36e879e318e2f11a
6
+ metadata.gz: 988688435e1c6aa8026772cc4813537101e410c86a4c032dd8369d271a5d519209c7b9ff61d132421d2fb42a4c5cfe533b3b6e994adc2039b930203f3279aad7
7
+ data.tar.gz: 696363e3cc63c7fc1986d1c898053c012c524179a40817eb632a0080669bae948f3f32d97abb5691a8a194042d100a688626d8f12525197ddbe3e42d92d4badb
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
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
data/lib/pg_conn.rb CHANGED
@@ -438,7 +438,8 @@ 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
- def call(name, *args)
441
+ #
442
+ def call(name, *args, proc: false)
442
443
  args_sql = args.map { |arg| # TODO: Use pg's encoder
443
444
  case arg
444
445
  when NilClass; "null"
@@ -451,19 +452,24 @@ module PgConn
451
452
  raise ArgumentError, "Unrecognized value: #{arg.inspect}"
452
453
  end
453
454
  }.join(", ")
454
- r = pg_exec "select * from #{name}(#{args_sql})"
455
- if r.ntuples == 0
456
- raise Error, "No records returned"
457
- elsif r.ntuples == 1
458
- if r.nfields == 1
459
- r.values[0][0]
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.values[0]
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.0
4
+ version: 0.4.1
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-05-29 00:00:00.000000000 Z
11
+ date: 2022-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg