pg_conn 0.32.0 → 0.32.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4afbef1cc74d235f8434c2c92a6537ec24b37cd36e85bb9f07eb6153e6c7938
4
- data.tar.gz: cd5af7434cb01ae1f873a7cb18a4cc350e425976c695b93252f2e36cefca2273
3
+ metadata.gz: dfb662385fd9e2cc88b6f06b7169b06b0daa5d893613eb9a917d0c0cc449ebb7
4
+ data.tar.gz: '09648f01535b6afe6c8e78f347e8e27215f8ac558488b2eafd9b46998835fc25'
5
5
  SHA512:
6
- metadata.gz: c94d25247ae2167f022a704bdf5b03691f87691dfe88c5187a5cbf2fb117c5ac252c3f649b5b0a20578cfe325b08cfff7f09e41da1d8f6c0bbf81c11cab501bf
7
- data.tar.gz: 689be40d28cb3a7ea0c84ab0109b7dc7749b16c47a8240b694ae746ff8602ebed6e5fa4394dc628d1df699a6c7c091db7f345c1ffb81cfc93e81e98d48c60ea0
6
+ metadata.gz: 4c56b84dee0d6e7073fec4b98466a03a8d88aae2c3a97bb98b855b1d48889f5611d90596bdefffe972ad4fb2602e46ae918d25e7ccbb7d88e6e2f40191967c7d
7
+ data.tar.gz: b36e951ac7073bae385b1fbf9a6e15ccdc93ffb30209e9476474723684d434fb655131a007c6d4e5caa71402713320deac21048a35f17788b400b4b7991e302e
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.32.0"
2
+ VERSION = "0.32.2"
3
3
  end
data/lib/pg_conn.rb CHANGED
@@ -58,8 +58,8 @@ module PgConn
58
58
  # or 'jsonb'
59
59
  #
60
60
  # Note that a tuple value (an array) must be quoted using #quote_tuple
61
- # because #quote_value would quote the tuple as an array instead of a list
62
- # of values
61
+ # because #quote_value would quote the tuple as an array value instead of a
62
+ # list of values
63
63
  #
64
64
  # The :elem_type option can be a postgres type name (String or Symbol) or
65
65
  # an array of type names. It is used as the required explicit element
@@ -329,6 +329,8 @@ module PgConn
329
329
  end
330
330
  end
331
331
 
332
+ # Mark argument as already being quoted. TODO: Make this the default in all
333
+ # quote methods
332
334
  def literal(arg) Literal.new(arg) end
333
335
 
334
336
  # Connection member method variations of the PgConn quote class methods
@@ -1022,8 +1024,15 @@ module PgConn
1022
1024
  end
1023
1025
 
1024
1026
  # Common implementation for #quote_record and #quote_records that avoids
1025
- # query the database multiple times while not duplication the code. the
1026
- # :array flag controls the mode
1027
+ # querying the database multiple times or duplication the code. The :array
1028
+ # flag is true when called via #quote_records
1029
+ #
1030
+ # @data can be a Hash, Array, or OpenStruct. Hash keys must be symbols or
1031
+ # strings, they belong to the same namespace so :k and "k" refer to the
1032
+ # same value
1033
+ #
1034
+ # Note that #quote_record_impl queries the database for information about
1035
+ # the type. TODO Cache this information?
1027
1036
  def quote_record_impl(datas, schema_name = nil, type, elem_types: nil, array: nil)
1028
1037
  pg_type = [schema_name, type].compact.join('.')
1029
1038
  fields = self.values(%(
@@ -1041,7 +1050,7 @@ module PgConn
1041
1050
  literals = datas.map { |data|
1042
1051
  values =
1043
1052
  case data
1044
- when Hash; fields.map { |f| data[f] }
1053
+ when Hash; fields.map { |f| (data.key?(f) ? data[f] : (data.key?(f.to_s) ? data[f.to_s] : nil)) }
1045
1054
  when OpenStruct; fields.map { |f| data.send(f) }
1046
1055
  when Array; data
1047
1056
  else
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.32.0
4
+ version: 0.32.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-19 00:00:00.000000000 Z
11
+ date: 2025-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg