pg_conn 0.17.0 → 0.17.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 +4 -4
- data/lib/pg_conn/version.rb +1 -1
- data/lib/pg_conn.rb +17 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebc1f6ad069daaf41d1bc7d58d40b3215bb53e03ad43de79251361f64ada5bd2
|
4
|
+
data.tar.gz: f746cf3be418cd9f5bf712e9ea2e2c549561f98ddb6741f5321464d6b71fb5e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 347112883473ba9ea49e4b041686b76f6c7c754fb5c438b39d3a7d1ffe1c8c5dbf131653f385700cfdba6023fe25c1090b301fcf701c737cbc586dc80ab74bad
|
7
|
+
data.tar.gz: b297c042cf2623f419b9a1aa777c103458b71591f92a8d6461be7a5fddf0c55a176bda3cdcf58fff6cc4d77858e5cdd581836d95c8d9bf7171eb044306006e91
|
data/lib/pg_conn/version.rb
CHANGED
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
|
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
|
268
|
-
def
|
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.
|
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-
|
11
|
+
date: 2024-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|