pg_conn 0.32.0 → 0.32.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4afbef1cc74d235f8434c2c92a6537ec24b37cd36e85bb9f07eb6153e6c7938
4
- data.tar.gz: cd5af7434cb01ae1f873a7cb18a4cc350e425976c695b93252f2e36cefca2273
3
+ metadata.gz: de05fd7cb9954d248fa17a1d770526254d3041581bd854c2e7ac1a3afd07d6c4
4
+ data.tar.gz: 47b0579c83826d3946fff342c9d95ec8ab3efc2119c6c7f117056d7188442582
5
5
  SHA512:
6
- metadata.gz: c94d25247ae2167f022a704bdf5b03691f87691dfe88c5187a5cbf2fb117c5ac252c3f649b5b0a20578cfe325b08cfff7f09e41da1d8f6c0bbf81c11cab501bf
7
- data.tar.gz: 689be40d28cb3a7ea0c84ab0109b7dc7749b16c47a8240b694ae746ff8602ebed6e5fa4394dc628d1df699a6c7c091db7f345c1ffb81cfc93e81e98d48c60ea0
6
+ metadata.gz: 4b77f809d2d2d8c431f78cd82b1f4359189731212f5cfa1b3818e043e886277951a2127a670b97259a311f05b750629cc431580eee110eab98eedaa02ff4217b
7
+ data.tar.gz: d9208f1e696f538e2502351a54c4ef17ef43cd8b59692ab2a5216976334b1333b0b1886c8d6e9031ae15b835e44023a77244ea586f0d6b4b9ddb50bed08a6dee
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.32.0"
2
+ VERSION = "0.32.1"
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] }
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.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: 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