pg_conn 0.17.0 → 0.17.2

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: b6f8840c223cb2dd9a6a5f8b2211e43184eb308114ffdd8bdc76d92f6ea03e16
4
- data.tar.gz: fbfad4033c2d21abb91b726c183001d4edbaf348d61cb425b4b003dd89a37f35
3
+ metadata.gz: ebc1f6ad069daaf41d1bc7d58d40b3215bb53e03ad43de79251361f64ada5bd2
4
+ data.tar.gz: f746cf3be418cd9f5bf712e9ea2e2c549561f98ddb6741f5321464d6b71fb5e3
5
5
  SHA512:
6
- metadata.gz: fe6647045b3bad635ed480e201967a20f0b11b5fd71bcbdec6766b6a2f056e3b0c8de045e87f56af90fb429130b2a9f105c46f5de5de31219b8384d18b27b3ca
7
- data.tar.gz: 5e114bd53908faf4a881799035276151ace147c63156cc006359e6483c182d0522d2a724f4e7b4fd551914739b23240c06a55319b46d4aa68c6bf65f0f8da095
6
+ metadata.gz: 347112883473ba9ea49e4b041686b76f6c7c754fb5c438b39d3a7d1ffe1c8c5dbf131653f385700cfdba6023fe25c1090b301fcf701c737cbc586dc80ab74bad
7
+ data.tar.gz: b297c042cf2623f419b9a1aa777c103458b71591f92a8d6461be7a5fddf0c55a176bda3cdcf58fff6cc4d77858e5cdd581836d95c8d9bf7171eb044306006e91
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.17.0"
2
+ VERSION = "0.17.2"
3
3
  end
data/lib/pg_conn.rb CHANGED
@@ -247,7 +247,7 @@ module PgConn
247
247
  # before quoting. This works by default for the regular types Integer,
248
248
  # true/false, Time/Date/DateTime, and arrays. Other types may require
249
249
  # special handling
250
- def quote_literal(value)
250
+ def quote_value(value)
251
251
  case value
252
252
  when String; @pg_connection.escape_literal(value)
253
253
  when Integer, Float; value.to_s
@@ -261,11 +261,22 @@ module PgConn
261
261
  end
262
262
  end
263
263
 
264
- # Quote array as a parenthesis-enclosed list of identifiers
265
- def quote_identifier_list(identifiers) = "(#{identifiers.map { quote_identifier(_1) }.join(', ')})"
266
264
 
267
- # Quote array as a parenthesis-enclosed list of literals
268
- def quote_literal_list(values) = "(#{values.map { quote_literal(_1) }.join(', ')})"
265
+ # Quote array as a comma-separated sequence of identifiers
266
+ def quote_identifier_seq(identifiers) = identifiers.map { quote_identifier(_1) }.join(', ')
267
+
268
+ # Quote array as a parenthesis-enclosed sequence of identifiers
269
+ def quote_identifier_list(identifiers) = "(#{quote_identifier_seq(identifiers)})"
270
+
271
+ # Quote array as a comma-separated sequence of values
272
+ def quote_value_seq(values) = values.map { quote_literal(_1) }.join(', ')
273
+
274
+ # Quote array as a parenthesis-enclosed list of value
275
+ def quote_value_list(values) = "(#{quote_value_seq(values)})"
276
+
277
+ # Old aliases. TODO Remove
278
+ def quote_literal(value) = quote_value(value)
279
+ def quote_literal_list(values) = quote_value_list(values)
269
280
 
270
281
  # :call-seq:
271
282
  # exist?(query)
@@ -558,6 +569,7 @@ module PgConn
558
569
 
559
570
  # Insert record(s) in a table. Returns the id of the inserted record(s)
560
571
  def insert(schema = nil, table, array_or_hash)
572
+ return [] if array_or_hash.empty?
561
573
  table = [schema, table].compact.join(".")
562
574
  is_array = array_or_hash.is_a?(Array)
563
575
  array = is_array ? array_or_hash : [array_or_hash]
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.17.0
4
+ version: 0.17.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: 2024-05-04 00:00:00.000000000 Z
11
+ date: 2024-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg