activerecord-insert_many 0.1.1 → 0.2.0

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
  SHA1:
3
- metadata.gz: a93dd222a89c193b4355915a9087d3b38f5b587b
4
- data.tar.gz: 9f592ba20d932a3c0351d7ccec8e5568f29df0ef
3
+ metadata.gz: 3d0c2ccf7d63fcc33b29d10baef77d505884c4f1
4
+ data.tar.gz: 29fd5e5ed70369751e34fee477240a61d6304041
5
5
  SHA512:
6
- metadata.gz: 8c57839bff48a2a14ff889e62ce968d23104b8739c40d88461402ef3108e979a7041fb0cbdb13633309ed6b5f8377f0de720405f92edcfae0da078087d13719c
7
- data.tar.gz: f4347115251b3e81d6663a238169781e8985d6f34fa54f6cda8ae4d0d78ffd4826ed66c9efca343bf3fe63f360011f5b900fdb813aa7e0eec278960066d8c60e
6
+ metadata.gz: b1872faa00486c75f45abe95407ba6433369e1232d7ffcf3cbd13293b787c5b5eb1c992f75b58888fd5c2aedff4fcaf3ab5031eb73a57c3a8ba69df4c2fe424d
7
+ data.tar.gz: 5faf2a908e26ebf9ab410db7a1e11c2f24d46793d41cfe657ff1210b1a19389eb4c53d4c697b56aad982e4545397edd756624252f80648a2ac36a952a9e26dee
@@ -23,7 +23,14 @@ module InsertManyStatement
23
23
  end
24
24
  end
25
25
 
26
- execute "INSERT INTO #{quote_table_name(table_name)} (#{key_list.join(', ')}) VALUES #{value_lists.map { |value| "(#{value.join(', ')})" }.join(",")}", "Fixture Insert"
26
+ primary_key_column = schema_cache.primary_keys(table_name)
27
+ returning = supports_returning? && primary_key_column.present? ? " RETURNING #{primary_key_column}" : ""
28
+
29
+ execute "INSERT INTO #{quote_table_name(table_name)} (#{key_list.join(', ')}) VALUES #{value_lists.map { |value| "(#{value.join(', ')})" }.join(",")}#{returning}", "Fixture Insert"
30
+ end
31
+
32
+ def supports_returning?
33
+ true
27
34
  end
28
35
  end
29
36
 
@@ -1,5 +1,5 @@
1
1
  module Activerecord
2
2
  module InsertMany
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-insert_many
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Booth
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-09-29 00:00:00.000000000 Z
12
+ date: 2015-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  requirements: []
92
92
  rubyforge_project:
93
- rubygems_version: 2.2.2
93
+ rubygems_version: 2.4.8
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Adds a method for bulk-inserted records using ActiveRecord