activerecord-import 0.2.8.rc1 → 0.2.8.rc2
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.8.
|
1
|
+
0.2.8.rc2
|
@@ -6,7 +6,7 @@ module ActiveRecord::Import::AbstractAdapter
|
|
6
6
|
# Returns the sum of the sizes of the passed in objects. This should
|
7
7
|
# probably be moved outside this class, but to where?
|
8
8
|
def sum_sizes( *objects ) # :nodoc:
|
9
|
-
objects.inject( 0 ){|sum,o| sum += o.
|
9
|
+
objects.inject( 0 ){ |sum,o| sum += o.bytesize }
|
10
10
|
end
|
11
11
|
|
12
12
|
def get_insert_value_sets( values, sql_size, max_bytes ) # :nodoc:
|
@@ -16,12 +16,12 @@ module ActiveRecord::Import::AbstractAdapter
|
|
16
16
|
comma_bytes = arr.size
|
17
17
|
sql_size_thus_far = sql_size + current_size + val.size + comma_bytes
|
18
18
|
if NO_MAX_PACKET == max_bytes or sql_size_thus_far <= max_bytes
|
19
|
-
current_size += val.
|
19
|
+
current_size += val.bytesize
|
20
20
|
arr << val
|
21
21
|
else
|
22
22
|
value_sets << arr
|
23
23
|
arr = [ val ]
|
24
|
-
current_size = val.
|
24
|
+
current_size = val.bytesize
|
25
25
|
end
|
26
26
|
|
27
27
|
# if we're on the last iteration push whatever we have in arr to value_sets
|
@@ -23,6 +23,6 @@ end
|
|
23
23
|
|
24
24
|
|
25
25
|
this_dir = Pathname.new File.dirname(__FILE__)
|
26
|
-
require this_dir.join("import")
|
27
|
-
require this_dir.join("active_record/adapters/abstract_adapter")
|
28
|
-
require this_dir.join("synchronize")
|
26
|
+
require this_dir.join("import").to_s
|
27
|
+
require this_dir.join("active_record/adapters/abstract_adapter").to_s
|
28
|
+
require this_dir.join("synchronize").to_s
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
def should_support_mysql_import_functionality
|
2
3
|
|
3
4
|
describe "building insert value sets" do
|
@@ -25,6 +26,24 @@ def should_support_mysql_import_functionality
|
|
25
26
|
assert_equal values[1], value_sets[1].first
|
26
27
|
assert_equal values[2], value_sets[2].first
|
27
28
|
end
|
29
|
+
|
30
|
+
context "data contains multi-byte chars" do
|
31
|
+
it "should properly build insert value set based on max packet allowed" do
|
32
|
+
# each accented e should be 2 bytes, so each entry is 6 bytes instead of 5
|
33
|
+
values = [
|
34
|
+
"('é')",
|
35
|
+
"('é')" ]
|
36
|
+
|
37
|
+
adapter = ActiveRecord::Base.connection.class
|
38
|
+
base_sql_size_in_bytes = 15
|
39
|
+
max_bytes = 26
|
40
|
+
|
41
|
+
values_size_in_bytes = adapter.sum_sizes( *values )
|
42
|
+
value_sets = adapter.get_insert_value_sets( values, base_sql_size_in_bytes, max_bytes )
|
43
|
+
|
44
|
+
assert_equal 2, value_sets.size, 'Two value sets were expected!'
|
45
|
+
end
|
46
|
+
end
|
28
47
|
end
|
29
48
|
|
30
49
|
describe "#import with :on_duplicate_key_update option (mysql specific functionality)" do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: activerecord-import
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 0.2.8.
|
5
|
+
version: 0.2.8.rc2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Zach Dennis
|
@@ -123,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
requirements:
|
124
124
|
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
hash:
|
126
|
+
hash: -763342084874399818
|
127
127
|
segments:
|
128
128
|
- 0
|
129
129
|
version: "0"
|