multi_insert 0.1.5 → 0.1.6
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 +4 -5
- 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: 6532ebc746eaa544c406349ddd1817bc149046a7
|
4
|
+
data.tar.gz: 8ebbc32e07ee43e5958c96c0dbdf04e45a172b46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac08e898e86852fa1bf278a36b9900058ed8f1881d93e8bbfb27ea068aaf521646c040d38599d3871ff2c2a02b9d63a860732355d931fc00c00f5e3a11cb334c
|
7
|
+
data.tar.gz: 49fab8f4e8ac646e09b64dd2b1951179bf102150ca89ff3174263c91e75ee98895bb937ab2971e7c35b7a96f49632080fe9a1be51f526a4fc624d4ef5c6211fb
|
@@ -5,19 +5,18 @@ module MultiInsert
|
|
5
5
|
def self.insert(table, columns, values, opts = {})
|
6
6
|
ar = ActiveRecord::Base.connection
|
7
7
|
|
8
|
-
|
9
|
-
options.merge!(opts)
|
8
|
+
opts.merge!({time: true})
|
10
9
|
|
11
|
-
now = Time.now.to_s(:db) if
|
10
|
+
now = Time.now.to_s(:db) if opts[:time]
|
12
11
|
table = ar.quote_table_name(table.to_s)
|
13
12
|
|
14
13
|
# Format columns
|
15
|
-
columns = columns + [:created_at, :updated_at] if
|
14
|
+
columns = columns + [:created_at, :updated_at] if opts[:time]
|
16
15
|
columns = columns.map!{|c| ar.quote_column_name(c.to_s)}
|
17
16
|
columns = join_params(columns)
|
18
17
|
|
19
18
|
# Format values
|
20
|
-
if
|
19
|
+
if opts[:time]
|
21
20
|
values = values.map{|v| v + [now, now]}
|
22
21
|
end
|
23
22
|
values = values.map{|v| join_params(v.map{|vv| ar.quote(vv.to_s)})}.join(',')
|
data/lib/multi_insert/version.rb
CHANGED