activerecord-import 2.2.0 → 2.3.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 +4 -4
- data/CHANGELOG.md +33 -0
- data/README.markdown +9 -9
- data/lib/activerecord-import/active_record/adapters/mysql2_proxy_adapter.rb +8 -0
- data/lib/activerecord-import/active_record/adapters/postgresql_proxy_adapter.rb +8 -0
- data/lib/activerecord-import/active_record/adapters/sqlite3_proxy_adapter.rb +8 -0
- data/lib/activerecord-import/active_record/adapters/trilogy_proxy_adapter.rb +8 -0
- data/lib/activerecord-import/adapters/active_record_proxy_adapter.rb +19 -0
- data/lib/activerecord-import/adapters/mysql2_proxy_adapter.rb +9 -0
- data/lib/activerecord-import/adapters/mysql_adapter.rb +10 -3
- data/lib/activerecord-import/adapters/postgresql_adapter.rb +1 -1
- data/lib/activerecord-import/adapters/postgresql_proxy_adapter.rb +9 -0
- data/lib/activerecord-import/adapters/sqlite3_proxy_adapter.rb +9 -0
- data/lib/activerecord-import/adapters/trilogy_proxy_adapter.rb +9 -0
- data/lib/activerecord-import/base.rb +0 -2
- data/lib/activerecord-import/import.rb +243 -207
- data/lib/activerecord-import/version.rb +1 -1
- metadata +13 -208
- data/.github/workflows/test.yaml +0 -165
- data/.gitignore +0 -37
- data/.rubocop.yml +0 -118
- data/.rubocop_todo.yml +0 -30
- data/Brewfile +0 -5
- data/Dockerfile +0 -23
- data/Gemfile +0 -63
- data/Rakefile +0 -75
- data/activerecord-import.gemspec +0 -28
- data/benchmarks/README +0 -32
- data/benchmarks/benchmark.rb +0 -72
- data/benchmarks/lib/base.rb +0 -143
- data/benchmarks/lib/cli_parser.rb +0 -111
- data/benchmarks/lib/float.rb +0 -17
- data/benchmarks/lib/mysql2_benchmark.rb +0 -21
- data/benchmarks/lib/output_to_csv.rb +0 -21
- data/benchmarks/lib/output_to_html.rb +0 -66
- data/benchmarks/models/test_innodb.rb +0 -5
- data/benchmarks/models/test_memory.rb +0 -5
- data/benchmarks/models/test_myisam.rb +0 -5
- data/benchmarks/schema/mysql2_schema.rb +0 -18
- data/docker-compose.yml +0 -34
- data/gemfiles/5.2.gemfile +0 -4
- data/gemfiles/6.0.gemfile +0 -4
- data/gemfiles/6.1.gemfile +0 -4
- data/gemfiles/7.0.gemfile +0 -4
- data/gemfiles/7.1.gemfile +0 -3
- data/gemfiles/7.2.gemfile +0 -3
- data/gemfiles/8.0.gemfile +0 -3
- data/test/adapters/janus_mysql2.rb +0 -3
- data/test/adapters/janus_trilogy.rb +0 -11
- data/test/adapters/jdbcmysql.rb +0 -3
- data/test/adapters/jdbcpostgresql.rb +0 -3
- data/test/adapters/jdbcsqlite3.rb +0 -3
- data/test/adapters/makara_postgis.rb +0 -3
- data/test/adapters/mysql2.rb +0 -3
- data/test/adapters/mysql2_makara.rb +0 -3
- data/test/adapters/mysql2_proxy.rb +0 -3
- data/test/adapters/mysql2spatial.rb +0 -3
- data/test/adapters/postgis.rb +0 -3
- data/test/adapters/postgresql.rb +0 -3
- data/test/adapters/postgresql_makara.rb +0 -3
- data/test/adapters/postgresql_proxy.rb +0 -3
- data/test/adapters/seamless_database_pool.rb +0 -3
- data/test/adapters/spatialite.rb +0 -3
- data/test/adapters/sqlite3.rb +0 -3
- data/test/adapters/trilogy.rb +0 -11
- data/test/database.yml.sample +0 -73
- data/test/github/database.yml +0 -85
- data/test/import_test.rb +0 -970
- data/test/janus_mysql2/import_test.rb +0 -8
- data/test/janus_trilogy/import_test.rb +0 -7
- data/test/jdbcmysql/import_test.rb +0 -7
- data/test/jdbcpostgresql/import_test.rb +0 -6
- data/test/jdbcsqlite3/import_test.rb +0 -6
- data/test/makara_postgis/import_test.rb +0 -10
- data/test/models/account.rb +0 -5
- data/test/models/alarm.rb +0 -4
- data/test/models/animal.rb +0 -8
- data/test/models/author.rb +0 -9
- data/test/models/bike_maker.rb +0 -10
- data/test/models/book.rb +0 -18
- data/test/models/car.rb +0 -5
- data/test/models/card.rb +0 -5
- data/test/models/chapter.rb +0 -6
- data/test/models/composite_book.rb +0 -19
- data/test/models/composite_chapter.rb +0 -12
- data/test/models/customer.rb +0 -18
- data/test/models/deck.rb +0 -8
- data/test/models/dictionary.rb +0 -6
- data/test/models/discount.rb +0 -5
- data/test/models/end_note.rb +0 -6
- data/test/models/group.rb +0 -5
- data/test/models/order.rb +0 -17
- data/test/models/playing_card.rb +0 -4
- data/test/models/promotion.rb +0 -5
- data/test/models/question.rb +0 -5
- data/test/models/rule.rb +0 -5
- data/test/models/tag.rb +0 -12
- data/test/models/tag_alias.rb +0 -11
- data/test/models/topic.rb +0 -31
- data/test/models/user.rb +0 -5
- data/test/models/user_token.rb +0 -6
- data/test/models/vendor.rb +0 -9
- data/test/models/widget.rb +0 -33
- data/test/mysql2/import_test.rb +0 -7
- data/test/mysql2_makara/import_test.rb +0 -8
- data/test/mysql2_proxy/import_test.rb +0 -6
- data/test/mysqlspatial2/import_test.rb +0 -8
- data/test/postgis/import_test.rb +0 -10
- data/test/postgresql/import_test.rb +0 -6
- data/test/postgresql_proxy/import_test.rb +0 -6
- data/test/schema/generic_schema.rb +0 -230
- data/test/schema/jdbcpostgresql_schema.rb +0 -3
- data/test/schema/mysql2_schema.rb +0 -21
- data/test/schema/postgis_schema.rb +0 -3
- data/test/schema/postgresql_schema.rb +0 -94
- data/test/schema/sqlite3_schema.rb +0 -15
- data/test/schema/version.rb +0 -12
- data/test/sqlite3/import_test.rb +0 -6
- data/test/support/active_support/test_case_extensions.rb +0 -73
- data/test/support/assertions.rb +0 -75
- data/test/support/factories.rb +0 -66
- data/test/support/generate.rb +0 -31
- data/test/support/mysql/import_examples.rb +0 -97
- data/test/support/postgresql/import_examples.rb +0 -642
- data/test/support/shared_examples/on_duplicate_key_ignore.rb +0 -45
- data/test/support/shared_examples/on_duplicate_key_update.rb +0 -437
- data/test/support/shared_examples/recursive_import.rb +0 -352
- data/test/support/sqlite3/import_examples.rb +0 -232
- data/test/synchronize_test.rb +0 -43
- data/test/test_helper.rb +0 -91
- data/test/trilogy/import_test.rb +0 -7
- data/test/value_sets_bytes_parser_test.rb +0 -106
- data/test/value_sets_records_parser_test.rb +0 -34
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
|
|
5
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
|
|
6
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")
|
|
7
|
-
|
|
8
|
-
should_support_mysql_import_functionality
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
|
|
5
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")
|
|
6
|
-
|
|
7
|
-
should_support_mysql_import_functionality
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
|
|
5
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")
|
|
6
|
-
|
|
7
|
-
should_support_mysql_import_functionality
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/postgresql/import_examples")
|
|
5
|
-
|
|
6
|
-
should_support_postgresql_import_functionality
|
|
7
|
-
|
|
8
|
-
if ActiveRecord::Base.connection.supports_on_duplicate_key_update?
|
|
9
|
-
should_support_postgresql_upsert_functionality
|
|
10
|
-
end
|
data/test/models/account.rb
DELETED
data/test/models/alarm.rb
DELETED
data/test/models/animal.rb
DELETED
data/test/models/author.rb
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Author < ActiveRecord::Base
|
|
4
|
-
if ENV['AR_VERSION'].to_f >= 8.0
|
|
5
|
-
has_many :composite_books, foreign_key: [:id, :author_id], inverse_of: :author
|
|
6
|
-
elsif ENV['AR_VERSION'].to_f >= 7.1
|
|
7
|
-
has_many :composite_books, query_constraints: [:id, :author_id], inverse_of: :author
|
|
8
|
-
end
|
|
9
|
-
end
|
data/test/models/bike_maker.rb
DELETED
data/test/models/book.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Book < ActiveRecord::Base
|
|
4
|
-
belongs_to :topic, inverse_of: :books
|
|
5
|
-
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
|
|
6
|
-
belongs_to :tag, foreign_key: [:tag_id, :parent_id] unless ENV["SKIP_COMPOSITE_PK"]
|
|
7
|
-
else
|
|
8
|
-
belongs_to :tag, query_constraints: [:tag_id, :parent_id] unless ENV["SKIP_COMPOSITE_PK"]
|
|
9
|
-
end
|
|
10
|
-
has_many :chapters, inverse_of: :book
|
|
11
|
-
has_many :discounts, as: :discountable
|
|
12
|
-
has_many :end_notes, inverse_of: :book
|
|
13
|
-
if ENV['AR_VERSION'].to_f >= 8.0
|
|
14
|
-
enum :status, [:draft, :published]
|
|
15
|
-
else
|
|
16
|
-
enum status: [:draft, :published]
|
|
17
|
-
end
|
|
18
|
-
end
|
data/test/models/car.rb
DELETED
data/test/models/card.rb
DELETED
data/test/models/chapter.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class CompositeBook < ActiveRecord::Base
|
|
4
|
-
self.primary_key = %i[id author_id]
|
|
5
|
-
belongs_to :author
|
|
6
|
-
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
|
|
7
|
-
unless ENV["SKIP_COMPOSITE_PK"]
|
|
8
|
-
has_many :composite_chapters, inverse_of: :composite_book,
|
|
9
|
-
foreign_key: [:id, :author_id]
|
|
10
|
-
end
|
|
11
|
-
else
|
|
12
|
-
has_many :composite_chapters, inverse_of: :composite_book,
|
|
13
|
-
query_constraints: [:id, :author_id]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def self.sequence_name
|
|
17
|
-
"composite_book_id_seq"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class CompositeChapter < ActiveRecord::Base
|
|
4
|
-
if ENV['AR_VERSION'].to_f >= 8.0
|
|
5
|
-
belongs_to :composite_book, inverse_of: :composite_chapters,
|
|
6
|
-
foreign_key: [:composite_book_id, :author_id]
|
|
7
|
-
elsif ENV['AR_VERSION'].to_f >= 7.1
|
|
8
|
-
belongs_to :composite_book, inverse_of: :composite_chapters,
|
|
9
|
-
query_constraints: [:composite_book_id, :author_id]
|
|
10
|
-
end
|
|
11
|
-
validates :title, presence: true
|
|
12
|
-
end
|
data/test/models/customer.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Customer < ActiveRecord::Base
|
|
4
|
-
unless ENV["SKIP_COMPOSITE_PK"]
|
|
5
|
-
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
|
|
6
|
-
has_many :orders,
|
|
7
|
-
inverse_of: :customer,
|
|
8
|
-
primary_key: %i(account_id id),
|
|
9
|
-
foreign_key: %i(account_id customer_id)
|
|
10
|
-
else
|
|
11
|
-
has_many :orders,
|
|
12
|
-
inverse_of: :customer,
|
|
13
|
-
primary_key: %i(account_id id),
|
|
14
|
-
query_constraints: %i(account_id customer_id)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
18
|
-
end
|
data/test/models/deck.rb
DELETED
data/test/models/dictionary.rb
DELETED
data/test/models/discount.rb
DELETED
data/test/models/end_note.rb
DELETED
data/test/models/group.rb
DELETED
data/test/models/order.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Order < ActiveRecord::Base
|
|
4
|
-
unless ENV["SKIP_COMPOSITE_PK"]
|
|
5
|
-
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
|
|
6
|
-
belongs_to :customer,
|
|
7
|
-
inverse_of: :orders,
|
|
8
|
-
primary_key: %i(account_id id),
|
|
9
|
-
foreign_key: %i(account_id customer_id)
|
|
10
|
-
else
|
|
11
|
-
belongs_to :customer,
|
|
12
|
-
inverse_of: :orders,
|
|
13
|
-
primary_key: %i(account_id id),
|
|
14
|
-
query_constraints: %i(account_id customer_id)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
data/test/models/playing_card.rb
DELETED
data/test/models/promotion.rb
DELETED
data/test/models/question.rb
DELETED
data/test/models/rule.rb
DELETED
data/test/models/tag.rb
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Tag < ActiveRecord::Base
|
|
4
|
-
if ENV['AR_VERSION'].to_f <= 7.0
|
|
5
|
-
self.primary_keys = :tag_id, :publisher_id unless ENV["SKIP_COMPOSITE_PK"]
|
|
6
|
-
else
|
|
7
|
-
self.primary_key = [:tag_id, :publisher_id] unless ENV["SKIP_COMPOSITE_PK"]
|
|
8
|
-
end
|
|
9
|
-
self.primary_key = [:tag_id, :publisher_id] unless ENV["SKIP_COMPOSITE_PK"]
|
|
10
|
-
has_many :books, inverse_of: :tag
|
|
11
|
-
has_many :tag_aliases, inverse_of: :tag
|
|
12
|
-
end
|
data/test/models/tag_alias.rb
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class TagAlias < ActiveRecord::Base
|
|
4
|
-
unless ENV["SKIP_COMPOSITE_PK"]
|
|
5
|
-
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
|
|
6
|
-
belongs_to :tag, foreign_key: [:tag_id, :parent_id], required: true
|
|
7
|
-
else
|
|
8
|
-
belongs_to :tag, query_constraints: [:tag_id, :parent_id], required: true
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
end
|
data/test/models/topic.rb
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class Topic < ActiveRecord::Base
|
|
4
|
-
if ENV['AR_VERSION'].to_f >= 6.0
|
|
5
|
-
self.ignored_columns = [:priority]
|
|
6
|
-
end
|
|
7
|
-
alias_attribute :name, :title
|
|
8
|
-
|
|
9
|
-
validates_presence_of :author_name
|
|
10
|
-
validates :title, numericality: { only_integer: true }, on: :context_test
|
|
11
|
-
validates :title, uniqueness: true
|
|
12
|
-
validates :content, uniqueness: true
|
|
13
|
-
validates :word_count, numericality: { greater_than: 0 }, if: :content?
|
|
14
|
-
|
|
15
|
-
validate -> { errors.add(:title, :validate_failed) if title == 'validate_failed' }
|
|
16
|
-
before_validation -> { errors.add(:title, :invalid) if title == 'invalid' }
|
|
17
|
-
|
|
18
|
-
has_many :books, inverse_of: :topic
|
|
19
|
-
has_many :novels, inverse_of: :topic, class_name: "Book"
|
|
20
|
-
belongs_to :parent, class_name: "Topic"
|
|
21
|
-
|
|
22
|
-
composed_of :description, mapping: [%w(title title), %w(author_name author_name)], allow_nil: true, class_name: "TopicDescription"
|
|
23
|
-
|
|
24
|
-
default_scope { where(approved: true) }
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
|
|
28
|
-
def word_count
|
|
29
|
-
@word_count ||= content.to_s.scan(/\w+/).count
|
|
30
|
-
end
|
|
31
|
-
end
|
data/test/models/user.rb
DELETED
data/test/models/user_token.rb
DELETED
data/test/models/vendor.rb
DELETED
data/test/models/widget.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class CustomCoder
|
|
4
|
-
def load(value)
|
|
5
|
-
if value.nil?
|
|
6
|
-
{}
|
|
7
|
-
else
|
|
8
|
-
YAML.load(value)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def dump(value)
|
|
13
|
-
YAML.dump(value)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
class Widget < ActiveRecord::Base
|
|
18
|
-
self.primary_key = :w_id
|
|
19
|
-
|
|
20
|
-
default_scope -> { where(active: true) }
|
|
21
|
-
|
|
22
|
-
if ENV['AR_VERSION'].to_f >= 7.1
|
|
23
|
-
serialize :data, coder: YAML
|
|
24
|
-
serialize :json_data, coder: JSON
|
|
25
|
-
serialize :custom_data, coder: CustomCoder.new
|
|
26
|
-
else
|
|
27
|
-
serialize :data, Hash
|
|
28
|
-
serialize :json_data, JSON
|
|
29
|
-
serialize :custom_data, CustomCoder.new
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
serialize :unspecified_data
|
|
33
|
-
end
|
data/test/mysql2/import_test.rb
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
|
|
5
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")
|
|
6
|
-
|
|
7
|
-
should_support_mysql_import_functionality
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
|
|
5
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
|
|
6
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")
|
|
7
|
-
|
|
8
|
-
should_support_mysql_import_functionality
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
|
|
5
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/assertions")
|
|
6
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/mysql/import_examples")
|
|
7
|
-
|
|
8
|
-
should_support_mysql_import_functionality
|
data/test/postgis/import_test.rb
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../test_helper")
|
|
4
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../support/postgresql/import_examples")
|
|
5
|
-
|
|
6
|
-
should_support_postgresql_import_functionality
|
|
7
|
-
|
|
8
|
-
if ActiveRecord::Base.connection.supports_on_duplicate_key_update?
|
|
9
|
-
should_support_postgresql_upsert_functionality
|
|
10
|
-
end
|