activerecord-import-rails4 0.5.0
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 +7 -0
- data/.gitignore +31 -0
- data/Appraisals +9 -0
- data/Gemfile +25 -0
- data/README.markdown +24 -0
- data/Rakefile +52 -0
- data/activerecord-import-rails4.gemspec +24 -0
- data/benchmarks/README +32 -0
- data/benchmarks/benchmark.rb +64 -0
- data/benchmarks/boot.rb +18 -0
- data/benchmarks/lib/base.rb +137 -0
- data/benchmarks/lib/cli_parser.rb +103 -0
- data/benchmarks/lib/float.rb +15 -0
- data/benchmarks/lib/mysql_benchmark.rb +22 -0
- data/benchmarks/lib/output_to_csv.rb +18 -0
- data/benchmarks/lib/output_to_html.rb +69 -0
- data/benchmarks/models/test_innodb.rb +3 -0
- data/benchmarks/models/test_memory.rb +3 -0
- data/benchmarks/models/test_myisam.rb +3 -0
- data/benchmarks/schema/mysql_schema.rb +16 -0
- data/gemfiles/rails3.gemfile +18 -0
- data/gemfiles/rails4.gemfile +18 -0
- data/lib/activerecord-import-rails4.rb +16 -0
- data/lib/activerecord-import-rails4/active_record/adapters/abstract_adapter.rb +10 -0
- data/lib/activerecord-import-rails4/active_record/adapters/jdbcmysql_adapter.rb +6 -0
- data/lib/activerecord-import-rails4/active_record/adapters/mysql2_adapter.rb +6 -0
- data/lib/activerecord-import-rails4/active_record/adapters/mysql_adapter.rb +6 -0
- data/lib/activerecord-import-rails4/active_record/adapters/postgresql_adapter.rb +7 -0
- data/lib/activerecord-import-rails4/active_record/adapters/seamless_database_pool_adapter.rb +7 -0
- data/lib/activerecord-import-rails4/active_record/adapters/sqlite3_adapter.rb +7 -0
- data/lib/activerecord-import-rails4/adapters/abstract_adapter.rb +119 -0
- data/lib/activerecord-import-rails4/adapters/mysql2_adapter.rb +5 -0
- data/lib/activerecord-import-rails4/adapters/mysql_adapter.rb +55 -0
- data/lib/activerecord-import-rails4/adapters/postgresql_adapter.rb +7 -0
- data/lib/activerecord-import-rails4/adapters/sqlite3_adapter.rb +5 -0
- data/lib/activerecord-import-rails4/base.rb +34 -0
- data/lib/activerecord-import-rails4/import.rb +387 -0
- data/lib/activerecord-import-rails4/mysql.rb +8 -0
- data/lib/activerecord-import-rails4/mysql2.rb +8 -0
- data/lib/activerecord-import-rails4/postgresql.rb +8 -0
- data/lib/activerecord-import-rails4/sqlite3.rb +8 -0
- data/lib/activerecord-import-rails4/synchronize.rb +60 -0
- data/lib/activerecord-import-rails4/version.rb +5 -0
- data/test/active_record/connection_adapter_test.rb +62 -0
- data/test/adapters/jdbcmysql.rb +1 -0
- data/test/adapters/mysql.rb +1 -0
- data/test/adapters/mysql2.rb +1 -0
- data/test/adapters/mysql2spatial.rb +1 -0
- data/test/adapters/mysqlspatial.rb +1 -0
- data/test/adapters/postgis.rb +1 -0
- data/test/adapters/postgresql.rb +1 -0
- data/test/adapters/seamless_database_pool.rb +1 -0
- data/test/adapters/spatialite.rb +1 -0
- data/test/adapters/sqlite3.rb +1 -0
- data/test/import_test.rb +321 -0
- data/test/jdbcmysql/import_test.rb +6 -0
- data/test/models/book.rb +3 -0
- data/test/models/group.rb +3 -0
- data/test/models/topic.rb +7 -0
- data/test/models/widget.rb +3 -0
- data/test/mysql/import_test.rb +6 -0
- data/test/mysql2/import_test.rb +6 -0
- data/test/mysqlspatial/import_test.rb +6 -0
- data/test/mysqlspatial2/import_test.rb +6 -0
- data/test/postgis/import_test.rb +4 -0
- data/test/postgresql/import_test.rb +4 -0
- data/test/schema/generic_schema.rb +102 -0
- data/test/schema/mysql_schema.rb +17 -0
- data/test/schema/version.rb +10 -0
- data/test/support/active_support/test_case_extensions.rb +67 -0
- data/test/support/factories.rb +19 -0
- data/test/support/generate.rb +29 -0
- data/test/support/mysql/assertions.rb +55 -0
- data/test/support/mysql/import_examples.rb +190 -0
- data/test/support/postgresql/import_examples.rb +21 -0
- data/test/synchronize_test.rb +22 -0
- data/test/test_helper.rb +48 -0
- metadata +197 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
def should_support_postgresql_import_functionality
|
3
|
+
describe "#supports_imports?" do
|
4
|
+
it "should support import" do
|
5
|
+
assert ActiveRecord::Base.supports_import?
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#import" do
|
10
|
+
it "should import with a single insert" do
|
11
|
+
# see ActiveRecord::ConnectionAdapters::AbstractAdapter test for more specifics
|
12
|
+
assert_difference "Topic.count", +10 do
|
13
|
+
result = Topic.import Build(3, :topics)
|
14
|
+
assert_equal 1, result.num_inserts
|
15
|
+
|
16
|
+
result = Topic.import Build(7, :topics)
|
17
|
+
assert_equal 1, result.num_inserts
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../test_helper', __FILE__)
|
2
|
+
|
3
|
+
describe ".synchronize" do
|
4
|
+
let(:topics){ Generate(3, :topics) }
|
5
|
+
let(:titles){ %w(one two three) }
|
6
|
+
|
7
|
+
setup do
|
8
|
+
# update records outside of ActiveRecord knowing about it
|
9
|
+
Topic.connection.execute( "UPDATE #{Topic.table_name} SET title='#{titles[0]}_haha' WHERE id=#{topics[0].id}", "Updating record 1 without ActiveRecord" )
|
10
|
+
Topic.connection.execute( "UPDATE #{Topic.table_name} SET title='#{titles[1]}_haha' WHERE id=#{topics[1].id}", "Updating record 2 without ActiveRecord" )
|
11
|
+
Topic.connection.execute( "UPDATE #{Topic.table_name} SET title='#{titles[2]}_haha' WHERE id=#{topics[2].id}", "Updating record 3 without ActiveRecord" )
|
12
|
+
end
|
13
|
+
|
14
|
+
it "reloads data for the specified records" do
|
15
|
+
Book.synchronize topics
|
16
|
+
|
17
|
+
actual_titles = topics.map(&:title)
|
18
|
+
assert_equal "#{titles[0]}_haha", actual_titles[0], "the first record was not correctly updated"
|
19
|
+
assert_equal "#{titles[1]}_haha", actual_titles[1], "the second record was not correctly updated"
|
20
|
+
assert_equal "#{titles[2]}_haha", actual_titles[2], "the third record was not correctly updated"
|
21
|
+
end
|
22
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
test_dir = Pathname.new File.dirname(__FILE__)
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require "fileutils"
|
7
|
+
|
8
|
+
ENV["RAILS_ENV"] = "test"
|
9
|
+
|
10
|
+
require "bundler"
|
11
|
+
Bundler.setup
|
12
|
+
|
13
|
+
require "logger"
|
14
|
+
require 'test/unit'
|
15
|
+
require "active_record"
|
16
|
+
require "active_record/fixtures"
|
17
|
+
require "active_support/test_case"
|
18
|
+
|
19
|
+
require "delorean"
|
20
|
+
require "ruby-debug" if RUBY_VERSION.to_f < 1.9
|
21
|
+
|
22
|
+
adapter = ENV["ARE_DB"] || "sqlite3"
|
23
|
+
|
24
|
+
FileUtils.mkdir_p 'log'
|
25
|
+
ActiveRecord::Base.logger = Logger.new("log/test.log")
|
26
|
+
ActiveRecord::Base.logger.level = Logger::DEBUG
|
27
|
+
ActiveRecord::Base.configurations["test"] = YAML.load_file(test_dir.join("database.yml"))[adapter]
|
28
|
+
|
29
|
+
require "activerecord-import-rails4"
|
30
|
+
ActiveRecord::Base.establish_connection "test"
|
31
|
+
|
32
|
+
ActiveSupport::Notifications.subscribe(/active_record.sql/) do |event, _, _, _, hsh|
|
33
|
+
ActiveRecord::Base.logger.info hsh[:sql]
|
34
|
+
end
|
35
|
+
|
36
|
+
require "factory_girl"
|
37
|
+
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each{ |file| require file }
|
38
|
+
|
39
|
+
# Load base/generic schema
|
40
|
+
require test_dir.join("schema/version")
|
41
|
+
require test_dir.join("schema/generic_schema")
|
42
|
+
adapter_schema = test_dir.join("schema/#{adapter}_schema.rb")
|
43
|
+
require adapter_schema if File.exists?(adapter_schema)
|
44
|
+
|
45
|
+
Dir[File.dirname(__FILE__) + "/models/*.rb"].each{ |file| require file }
|
46
|
+
|
47
|
+
# Prevent this deprecation warning from breaking the tests.
|
48
|
+
Rake::FileList.send(:remove_method, :import)
|
metadata
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: activerecord-import-rails4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zach Dennis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: appraisal
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Extraction of the ActiveRecord::Base#import functionality from ar-extensions
|
56
|
+
for Rails 3 and beyond
|
57
|
+
email:
|
58
|
+
- zach.dennis@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Appraisals
|
65
|
+
- Gemfile
|
66
|
+
- README.markdown
|
67
|
+
- Rakefile
|
68
|
+
- activerecord-import-rails4.gemspec
|
69
|
+
- benchmarks/README
|
70
|
+
- benchmarks/benchmark.rb
|
71
|
+
- benchmarks/boot.rb
|
72
|
+
- benchmarks/lib/base.rb
|
73
|
+
- benchmarks/lib/cli_parser.rb
|
74
|
+
- benchmarks/lib/float.rb
|
75
|
+
- benchmarks/lib/mysql_benchmark.rb
|
76
|
+
- benchmarks/lib/output_to_csv.rb
|
77
|
+
- benchmarks/lib/output_to_html.rb
|
78
|
+
- benchmarks/models/test_innodb.rb
|
79
|
+
- benchmarks/models/test_memory.rb
|
80
|
+
- benchmarks/models/test_myisam.rb
|
81
|
+
- benchmarks/schema/mysql_schema.rb
|
82
|
+
- gemfiles/rails3.gemfile
|
83
|
+
- gemfiles/rails4.gemfile
|
84
|
+
- lib/activerecord-import-rails4.rb
|
85
|
+
- lib/activerecord-import-rails4/active_record/adapters/abstract_adapter.rb
|
86
|
+
- lib/activerecord-import-rails4/active_record/adapters/jdbcmysql_adapter.rb
|
87
|
+
- lib/activerecord-import-rails4/active_record/adapters/mysql2_adapter.rb
|
88
|
+
- lib/activerecord-import-rails4/active_record/adapters/mysql_adapter.rb
|
89
|
+
- lib/activerecord-import-rails4/active_record/adapters/postgresql_adapter.rb
|
90
|
+
- lib/activerecord-import-rails4/active_record/adapters/seamless_database_pool_adapter.rb
|
91
|
+
- lib/activerecord-import-rails4/active_record/adapters/sqlite3_adapter.rb
|
92
|
+
- lib/activerecord-import-rails4/adapters/abstract_adapter.rb
|
93
|
+
- lib/activerecord-import-rails4/adapters/mysql2_adapter.rb
|
94
|
+
- lib/activerecord-import-rails4/adapters/mysql_adapter.rb
|
95
|
+
- lib/activerecord-import-rails4/adapters/postgresql_adapter.rb
|
96
|
+
- lib/activerecord-import-rails4/adapters/sqlite3_adapter.rb
|
97
|
+
- lib/activerecord-import-rails4/base.rb
|
98
|
+
- lib/activerecord-import-rails4/import.rb
|
99
|
+
- lib/activerecord-import-rails4/mysql.rb
|
100
|
+
- lib/activerecord-import-rails4/mysql2.rb
|
101
|
+
- lib/activerecord-import-rails4/postgresql.rb
|
102
|
+
- lib/activerecord-import-rails4/sqlite3.rb
|
103
|
+
- lib/activerecord-import-rails4/synchronize.rb
|
104
|
+
- lib/activerecord-import-rails4/version.rb
|
105
|
+
- test/active_record/connection_adapter_test.rb
|
106
|
+
- test/adapters/jdbcmysql.rb
|
107
|
+
- test/adapters/mysql.rb
|
108
|
+
- test/adapters/mysql2.rb
|
109
|
+
- test/adapters/mysql2spatial.rb
|
110
|
+
- test/adapters/mysqlspatial.rb
|
111
|
+
- test/adapters/postgis.rb
|
112
|
+
- test/adapters/postgresql.rb
|
113
|
+
- test/adapters/seamless_database_pool.rb
|
114
|
+
- test/adapters/spatialite.rb
|
115
|
+
- test/adapters/sqlite3.rb
|
116
|
+
- test/import_test.rb
|
117
|
+
- test/jdbcmysql/import_test.rb
|
118
|
+
- test/models/book.rb
|
119
|
+
- test/models/group.rb
|
120
|
+
- test/models/topic.rb
|
121
|
+
- test/models/widget.rb
|
122
|
+
- test/mysql/import_test.rb
|
123
|
+
- test/mysql2/import_test.rb
|
124
|
+
- test/mysqlspatial/import_test.rb
|
125
|
+
- test/mysqlspatial2/import_test.rb
|
126
|
+
- test/postgis/import_test.rb
|
127
|
+
- test/postgresql/import_test.rb
|
128
|
+
- test/schema/generic_schema.rb
|
129
|
+
- test/schema/mysql_schema.rb
|
130
|
+
- test/schema/version.rb
|
131
|
+
- test/support/active_support/test_case_extensions.rb
|
132
|
+
- test/support/factories.rb
|
133
|
+
- test/support/generate.rb
|
134
|
+
- test/support/mysql/assertions.rb
|
135
|
+
- test/support/mysql/import_examples.rb
|
136
|
+
- test/support/postgresql/import_examples.rb
|
137
|
+
- test/synchronize_test.rb
|
138
|
+
- test/test_helper.rb
|
139
|
+
homepage: http://github.com/zdennis/activerecord-import
|
140
|
+
licenses: []
|
141
|
+
metadata: {}
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 1.9.2
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - '>='
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubyforge_project:
|
158
|
+
rubygems_version: 2.0.0
|
159
|
+
signing_key:
|
160
|
+
specification_version: 4
|
161
|
+
summary: Bulk-loading extension for ActiveRecord
|
162
|
+
test_files:
|
163
|
+
- test/active_record/connection_adapter_test.rb
|
164
|
+
- test/adapters/jdbcmysql.rb
|
165
|
+
- test/adapters/mysql.rb
|
166
|
+
- test/adapters/mysql2.rb
|
167
|
+
- test/adapters/mysql2spatial.rb
|
168
|
+
- test/adapters/mysqlspatial.rb
|
169
|
+
- test/adapters/postgis.rb
|
170
|
+
- test/adapters/postgresql.rb
|
171
|
+
- test/adapters/seamless_database_pool.rb
|
172
|
+
- test/adapters/spatialite.rb
|
173
|
+
- test/adapters/sqlite3.rb
|
174
|
+
- test/import_test.rb
|
175
|
+
- test/jdbcmysql/import_test.rb
|
176
|
+
- test/models/book.rb
|
177
|
+
- test/models/group.rb
|
178
|
+
- test/models/topic.rb
|
179
|
+
- test/models/widget.rb
|
180
|
+
- test/mysql/import_test.rb
|
181
|
+
- test/mysql2/import_test.rb
|
182
|
+
- test/mysqlspatial/import_test.rb
|
183
|
+
- test/mysqlspatial2/import_test.rb
|
184
|
+
- test/postgis/import_test.rb
|
185
|
+
- test/postgresql/import_test.rb
|
186
|
+
- test/schema/generic_schema.rb
|
187
|
+
- test/schema/mysql_schema.rb
|
188
|
+
- test/schema/version.rb
|
189
|
+
- test/support/active_support/test_case_extensions.rb
|
190
|
+
- test/support/factories.rb
|
191
|
+
- test/support/generate.rb
|
192
|
+
- test/support/mysql/assertions.rb
|
193
|
+
- test/support/mysql/import_examples.rb
|
194
|
+
- test/support/postgresql/import_examples.rb
|
195
|
+
- test/synchronize_test.rb
|
196
|
+
- test/test_helper.rb
|
197
|
+
has_rdoc:
|