pg_conn 0.13.0 → 0.13.1

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: 7c975d085fc3e3f58a72fbb13d0e5ce9428254969e8723c8af0d6577381f0f70
4
- data.tar.gz: 6a786d3466d2c0661b22ee738212a3b8a37afca86a99dbde59773e5d47b7a5f5
3
+ metadata.gz: 30f37deaa02a7ce6c10c42be3b5432ac3e80c21fd82ec8a0d33d10cfc29ad904
4
+ data.tar.gz: b78696618951f214e39f5e075ad1d657e86d0d5dda691b5f9b081e51b45b40a1
5
5
  SHA512:
6
- metadata.gz: 6710fbd23379b8e1b13bd41dda8ce206fcefca30c93f43f2be0f4b7e437d854d50c89aa429cb70f52901eb7d4b515a810012801adc334b2082307dcc4ca2aaa9
7
- data.tar.gz: 838a84b8f67710abcee3381f3691e93fab21c9d07ec48efa1480faec5c4b7621a5904d1000f2a62666c998f30b499de06c74eada70fac6609ea601beabf7b976
6
+ metadata.gz: 68bab843ada37c8214bd7281bda915a6ec509dd337b4cae40384308d60408bfdc7de4abd10eefc94123248d438db4f01942ba7bdc2fd4e17f3dd28096e07aaac
7
+ data.tar.gz: 1a64027e97471f53ab114f617de495be2f4adab7e64cd30cf63b91a9a698462cae13531b990c3f96241d008e7a343b7163bcde8bd1d0371efb1935a741215384
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.13.0"
2
+ VERSION = "0.13.1"
3
3
  end
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
- array = array_or_hash.is_a?(Array) ? array_or_hash : [array_or_hash]
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
- exec %(insert into #{table} #{identifiers} values #{literals})
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_conn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen