multi_insert 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/multi_insert/query_builder.rb +9 -9
- data/lib/multi_insert/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc88de09d021aaa85d16bbf4d876a69a87a4a921
|
4
|
+
data.tar.gz: 4f3dd8796f7b8e050ff23123d0708702a78385d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ce752cd597546875031f34724d5f05f7b6abb54db882773e2c00e5204c5f55509ab3532cfcdda83ae531f11cf626888dcfb9bf9ca03f431d9aea21ec8d2cde2
|
7
|
+
data.tar.gz: 8115180ddf1d1662d3eb2bda8f49cadf80f2bc89eb5af0e9eb0e6b668b6138c68fc3746455325ee61ba0148af612ff28263e6aaab28da3aae2386e425fc2e6cf
|
@@ -14,24 +14,24 @@ module MultiInsert
|
|
14
14
|
# Format columns
|
15
15
|
columns = columns + [:created_at, :updated_at] if options[:time]
|
16
16
|
columns = columns.map!{|c| ar.quote_column_name(c.to_s)}
|
17
|
-
columns =
|
17
|
+
columns = join_params(columns)
|
18
18
|
|
19
19
|
# Format values
|
20
20
|
if options[:time]
|
21
21
|
values = values.map{|v| v + [now, now]}
|
22
22
|
end
|
23
|
-
values = values.map{|v|
|
23
|
+
values = values.map{|v| join_params(v.map{|vv| ar.quote(vv.to_s)})}.join(',')
|
24
24
|
|
25
25
|
"INSERT INTO #{table} #{columns} VALUES #{values}"
|
26
26
|
end
|
27
|
-
end
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
def self.returning(columns)
|
29
|
+
columns = columns.map{|c| ActiveRecord::Base.connection.quote_column_name(c.to_s)}.join(',')
|
30
|
+
"RETURNING #{columns}"
|
31
|
+
end
|
33
32
|
|
34
|
-
|
35
|
-
|
33
|
+
def self.join_params(params)
|
34
|
+
"(" + params.join(',') + ")"
|
35
|
+
end
|
36
36
|
end
|
37
37
|
end
|
data/lib/multi_insert/version.rb
CHANGED