pg_conn 0.18.0 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/TODO +19 -0
  3. data/lib/pg_conn/version.rb +1 -1
  4. data/lib/pg_conn.rb +18 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7b067cc4d9e831d6c30c135a351a05362953d75414d888a9c012105117dfcd1
4
- data.tar.gz: 17eeef29e2844094019bf16890a98cade8b788f2465eb63797a46cdac66d3b93
3
+ metadata.gz: 91bfceabfdba86eba789108cea2718e382fe6849b580ef3be3a428a8f08ab45e
4
+ data.tar.gz: 0014ae1ccc9c6cf95f63fce78d5a094b7068e711ed18d0edcdaafe35d47ef04b
5
5
  SHA512:
6
- metadata.gz: d4e77389acba0ebdd70d4e22440db2449129184bec8a775019d9e8e5a1e601990b276be89482286f4e24c7a35767f3aeba8293a6e2de9832600a16183dfe97db
7
- data.tar.gz: 348441a6c040059ad68f648146c468d52e914841411f282efde924cee707d97ef7616092612b7d82844a0ededbb05e8bc33122cf408458f040cd9701214ddebc
6
+ metadata.gz: 6302b2051fd7a152b026ed7a412ad9025ae7fbdb6f260173c5731c123f367c7535a9522e2654ccc09950d14c9e3009c1daf6d52fa7fc3114c3b9f196e6db0570
7
+ data.tar.gz: c793534b923e08cc22121dc824c858003cb495e2453cb77cd7007672e242a62ff8819ab966f2f9d70a552f3a080da2627c1ec1211990eefcbe87bdcc1a5c06e8
data/TODO CHANGED
@@ -1,4 +1,23 @@
1
1
  TODO
2
+ o db.context(schema: app_portal, transaction: true) { ... }
3
+ db.context(set: app_portal, transaction: true) { ... }
4
+ db.context(add: app_portal, transaction: true) { ... }
5
+
6
+ o In the doc; compare a VisualBasic call to a function with PgConn's:
7
+
8
+ Set cmd = Server.CreateObject("ADODB.Command")
9
+ cmd.CommandText = "sp_nic_update_comtext"
10
+ cmd.CommandType = adCmdStoredProc
11
+ cmd.Parameters.Append cmd.CreateParameter("Id", adGUID, adParamInput, ,strId)
12
+ cmd.Parameters.Append cmd.CreateParameter("comtext", adVarWChar, adParamInput,2048 ,strComtext)
13
+ cmd.Parameters.Append cmd.CreateParameter("UserId", adGUID, adParamInput, , Site.CurrentUser.Id.ToString())
14
+ cnn.ExecuteCommandNonQuery cmd
15
+
16
+ vs
17
+
18
+ server.call :sp_nic_update_comtext, str_id, str_comtext, site.current_user.id
19
+
20
+
2
21
  o Have a 'with' method that combines multiple brachet-methods:
3
22
 
4
23
  conn.with(schema: public, transation: true) { ... }
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.18.0"
2
+ VERSION = "0.19.0"
3
3
  end
data/lib/pg_conn.rb CHANGED
@@ -507,7 +507,7 @@ module PgConn
507
507
  # Returns a hash from the first field to a tuple of the remaining fields.
508
508
  # If there is only one remaining field then that value is used instead of a
509
509
  # tuple of that value. The optional +key+ argument sets the mapping field
510
- def map(query, key = nil)
510
+ def map(query, key = nil) # TODO Swap arguments
511
511
  r = pg_exec(query)
512
512
  begin
513
513
  key = (key || r.fname(0)).to_s
@@ -525,6 +525,23 @@ module PgConn
525
525
  h
526
526
  end
527
527
 
528
+ def multimap(query, key = nil)
529
+ r = pg_exec(query)
530
+ begin
531
+ key = (key || r.fname(0)).to_s
532
+ key_index = r.fnumber(key.to_s)
533
+ one = (r.nfields == 2)
534
+ rescue ArgumentError
535
+ raise Error, "Can't find column #{key}"
536
+ end
537
+ h = {}
538
+ r.each_row { |row|
539
+ key_value = row.delete_at(key_index)
540
+ (h[key_value] ||= []) << (one ? row.first : row)
541
+ }
542
+ h
543
+ end
544
+
528
545
  # Return the value of calling the given function (which can be a String or
529
546
  # a Symbol and can contain the schema of the function). It dynamically
530
547
  # detects the structure of the result and return a value or an array of
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.18.0
4
+ version: 0.19.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-05-15 00:00:00.000000000 Z
11
+ date: 2024-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg