activerecord-insert_many 0.4.1 → 0.4.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/activerecord/insert_many.rb +9 -6
- data/lib/activerecord/insert_many/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f3a11efa931742fc96cb84de9f2f605fd9e1e42
|
4
|
+
data.tar.gz: e12ef9f2fac223018001c3c6cb1e09d726e54eb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e107a6951bd83c3fd519beccac395f6bbc3f89935c01c361601a00dd4784748a64835d8caa088f1aff4da9d266d431b9fe3a43ec3298339bf3bfdf138aeeedf
|
7
|
+
data.tar.gz: 48e70bc7be5c1027b80c45c8fb50c45a06cc1ae2fd65061a5e753718ea7db5acabc257cc1f8c6d63a1919543b2934b43920cdcfd25184135065539e20efa022a
|
@@ -66,14 +66,17 @@ module ActiveRecord
|
|
66
66
|
conflict_columns = Array.wrap(conflict.fetch(:column, schema_cache.primary_keys(table_name)))
|
67
67
|
raise ArgumentError, "To use the :on_conflict option, you must specify :column" unless conflict_columns.any?
|
68
68
|
|
69
|
+
conflict_do = conflict.fetch(:do)
|
70
|
+
raise ArgumentError, "#{conflict_do.inspect} is an unknown value for conflict[:do]; must be :nothing or :update" unless [:nothing, :update].member?(conflict_do)
|
71
|
+
|
69
72
|
conflict_columns = conflict_columns.map(&method(:quote_column_name))
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
sql << "
|
73
|
+
sql << " ON CONFLICT(#{conflict_columns.join(",")})"
|
74
|
+
sql << " WHERE #{conflict[:where]}" if conflict[:where]
|
75
|
+
|
76
|
+
if conflict_do == :nothing
|
77
|
+
sql << " DO NOTHING"
|
75
78
|
else
|
76
|
-
|
79
|
+
sql << " DO UPDATE SET #{(key_list - conflict_columns).map { |key| "#{key} = excluded.#{key}" }.join(", ")}"
|
77
80
|
end
|
78
81
|
end
|
79
82
|
|
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.4.
|
4
|
+
version: 0.4.2
|
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:
|
12
|
+
date: 2018-05-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|