pg_conn 0.13.0 → 0.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pg_conn/version.rb +1 -1
- data/lib/pg_conn.rb +5 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30f37deaa02a7ce6c10c42be3b5432ac3e80c21fd82ec8a0d33d10cfc29ad904
|
4
|
+
data.tar.gz: b78696618951f214e39f5e075ad1d657e86d0d5dda691b5f9b081e51b45b40a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68bab843ada37c8214bd7281bda915a6ec509dd337b4cae40384308d60408bfdc7de4abd10eefc94123248d438db4f01942ba7bdc2fd4e17f3dd28096e07aaac
|
7
|
+
data.tar.gz: 1a64027e97471f53ab114f617de495be2f4adab7e64cd30cf63b91a9a698462cae13531b990c3f96241d008e7a343b7163bcde8bd1d0371efb1935a741215384
|
data/lib/pg_conn/version.rb
CHANGED
data/lib/pg_conn.rb
CHANGED
@@ -547,13 +547,15 @@ module PgConn
|
|
547
547
|
end
|
548
548
|
end
|
549
549
|
|
550
|
-
# Insert record(s) in a table
|
550
|
+
# Insert record(s) in a table. Returns the id of the inserted record(s)
|
551
551
|
def insert(schema = nil, table, array_or_hash)
|
552
552
|
table = [schema, table].compact.join(".")
|
553
|
-
|
553
|
+
is_array = array_or_hash.is_a?(Array)
|
554
|
+
array = is_array ? array_or_hash : [array_or_hash]
|
554
555
|
identifiers = quote_identifier_list(array.first.keys)
|
555
556
|
literals = array.map { |hash| quote_literal_list(hash.values) }.join(", ")
|
556
|
-
|
557
|
+
method = (is_array ? :values : :value)
|
558
|
+
self.send method, %(insert into #{table} #{identifiers} values #{literals} returning id)
|
557
559
|
end
|
558
560
|
|
559
561
|
# Update record(s)
|