activerecord-import 1.8.0 → 2.2.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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yaml +24 -6
  3. data/.rubocop.yml +6 -3
  4. data/CHANGELOG.md +35 -0
  5. data/Gemfile +5 -11
  6. data/README.markdown +2 -2
  7. data/Rakefile +4 -0
  8. data/benchmarks/benchmark.rb +0 -2
  9. data/benchmarks/lib/base.rb +6 -3
  10. data/benchmarks/lib/cli_parser.rb +8 -6
  11. data/gemfiles/8.0.gemfile +3 -0
  12. data/lib/activerecord-import/adapters/sqlite3_adapter.rb +1 -1
  13. data/lib/activerecord-import/base.rb +4 -0
  14. data/lib/activerecord-import/import.rb +8 -14
  15. data/lib/activerecord-import/version.rb +1 -1
  16. data/test/adapters/janus_mysql2.rb +3 -0
  17. data/test/adapters/janus_trilogy.rb +11 -0
  18. data/test/adapters/mysql2_proxy.rb +3 -0
  19. data/test/adapters/postgresql_proxy.rb +3 -0
  20. data/test/adapters/trilogy.rb +2 -0
  21. data/test/database.yml.sample +14 -0
  22. data/test/github/database.yml +15 -2
  23. data/test/import_test.rb +15 -39
  24. data/test/janus_mysql2/import_test.rb +8 -0
  25. data/test/janus_trilogy/import_test.rb +7 -0
  26. data/test/models/author.rb +3 -1
  27. data/test/models/book.rb +6 -2
  28. data/test/models/composite_book.rb +1 -1
  29. data/test/models/composite_chapter.rb +4 -1
  30. data/test/models/customer.rb +1 -1
  31. data/test/models/order.rb +1 -1
  32. data/test/models/tag_alias.rb +1 -1
  33. data/test/models/topic.rb +1 -0
  34. data/test/mysql2_proxy/import_test.rb +6 -0
  35. data/test/postgresql_proxy/import_test.rb +6 -0
  36. data/test/support/active_support/test_case_extensions.rb +1 -5
  37. data/test/support/mysql/import_examples.rb +6 -8
  38. data/test/support/postgresql/import_examples.rb +37 -53
  39. data/test/support/shared_examples/recursive_import.rb +39 -0
  40. data/test/test_helper.rb +9 -20
  41. metadata +23 -12
  42. data/gemfiles/4.2.gemfile +0 -4
  43. data/gemfiles/5.0.gemfile +0 -4
  44. data/gemfiles/5.1.gemfile +0 -4
  45. data/lib/activerecord-import/mysql2.rb +0 -9
  46. data/lib/activerecord-import/postgresql.rb +0 -9
  47. data/lib/activerecord-import/sqlite3.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1478b29daf1e757c91a0ca8693bb1b03f9a90daa2fe02f0959576bcec900d85
4
- data.tar.gz: dc938a1936c931182675a118ad24a37e2a7c5a27c0419e5bd947e0ec35aa4334
3
+ metadata.gz: f7cd19fa557186daf34db96db71f26a7db70b15e66a0a42eaab33be304945ab0
4
+ data.tar.gz: ff8afe763d437210ea1c78e21bacd0b4ae84f113fbadbda087077bf402f08e64
5
5
  SHA512:
6
- metadata.gz: e276196113f433c8989a9a06cfad36df650105183a5559a548bdd8a04bd2da22db36ca996d2d0d04c4561b33ceb44559b50b4ad98e0a2d9f050b8084ee99c8e6
7
- data.tar.gz: e699052ac2499bac23a9955fef71df853050767785d573523e23a1d216cfba9cb75b81b0db9f5e2afac02afbcb416563af6e7a2bf69f6d1288c6e6c71aeb7e5c
6
+ metadata.gz: 402d2087c8c35a2adfa3787ee4e183883df74cc1f4ad2276de1227ba9778b630bfbee546faa3b53b7dcbe1142232bd7d03de046ccab5c6caa5c475a3bc4f15c1
7
+ data.tar.gz: ef5ce7d4dba744b3c58a0affbe326b50d764c7e4c4726b468ad4d18eacee13fbaa8d7b5d78459bc048e8eeb0628cf34b52a59f759f0a1f4d9d491b7439d5845a
@@ -21,6 +21,7 @@ jobs:
21
21
  ports:
22
22
  - 3306:3306
23
23
  env:
24
+ MYSQL_HOST: 127.0.0.1
24
25
  MYSQL_ROOT_PASSWORD: root
25
26
  MYSQL_USER: github
26
27
  MYSQL_PASSWORD: github
@@ -36,6 +37,8 @@ jobs:
36
37
  ruby:
37
38
  - 3.3
38
39
  env:
40
+ - AR_VERSION: '8.0'
41
+ RUBYOPT: --enable-frozen-string-literal
39
42
  - AR_VERSION: '7.2'
40
43
  RUBYOPT: --enable-frozen-string-literal
41
44
  - AR_VERSION: '7.1'
@@ -45,6 +48,9 @@ jobs:
45
48
  - AR_VERSION: 6.1
46
49
  RUBYOPT: --enable-frozen-string-literal
47
50
  include:
51
+ - ruby: 3.2
52
+ env:
53
+ AR_VERSION: '8.0'
48
54
  - ruby: 3.2
49
55
  env:
50
56
  AR_VERSION: '7.2'
@@ -72,7 +78,7 @@ jobs:
72
78
  - ruby: '3.0'
73
79
  env:
74
80
  AR_VERSION: 6.1
75
- - ruby: jruby-9.4.5.0
81
+ - ruby: jruby-9.4.8.0
76
82
  env:
77
83
  AR_VERSION: '7.0'
78
84
  - ruby: 2.7
@@ -84,7 +90,7 @@ jobs:
84
90
  - ruby: 2.7
85
91
  env:
86
92
  AR_VERSION: '6.0'
87
- - ruby: jruby-9.3.10.0
93
+ - ruby: jruby-9.3.15.0
88
94
  env:
89
95
  AR_VERSION: '6.1'
90
96
  - ruby: 2.6
@@ -96,6 +102,10 @@ jobs:
96
102
  DB_DATABASE: activerecord_import_test
97
103
  steps:
98
104
  - uses: actions/checkout@v4
105
+ - name: Install SQLite3 Development Library
106
+ run: |
107
+ sudo apt-get update
108
+ sudo apt-get install libsqlite3-dev
99
109
  - uses: ruby/setup-ruby@v1
100
110
  with:
101
111
  ruby-version: ${{ matrix.ruby }}
@@ -103,8 +113,6 @@ jobs:
103
113
  rubygems: latest
104
114
  - name: Set up databases
105
115
  run: |
106
- sudo /etc/init.d/mysql start
107
- mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }} CHARACTER SET utf8 COLLATE utf8_general_ci;' -u root -proot
108
116
  psql -h localhost -U postgres -c 'create database ${{ env.DB_DATABASE }};'
109
117
  psql -h localhost -U postgres -d ${{ env.DB_DATABASE }} -c 'create extension if not exists hstore;'
110
118
  psql -h localhost -U postgres -c 'create extension if not exists postgis;'
@@ -117,11 +125,14 @@ jobs:
117
125
  bundle exec rake test:mysql2
118
126
  bundle exec rake test:mysql2_makara
119
127
  bundle exec rake test:mysql2spatial
128
+ bundle exec rake test:mysql2_proxy
129
+ bundle exec rake test:janus_mysql2
120
130
  - name: Run tests with postgresql
121
131
  run: |
122
132
  bundle exec rake test:postgis
123
133
  bundle exec rake test:postgresql
124
134
  bundle exec rake test:postgresql_makara
135
+ bundle exec rake test:postgresql_proxy
125
136
  - name: Run tests with seamless_database_pool
126
137
  run: |
127
138
  bundle exec rake test:seamless_database_pool
@@ -132,16 +143,23 @@ jobs:
132
143
  bundle exec rake test:sqlite3
133
144
  - name: Run trilogy tests
134
145
  if: ${{ matrix.env.AR_VERSION >= '7.0' && !startsWith(matrix.ruby, 'jruby') }}
135
- run: bundle exec rake test:trilogy
146
+ run: |
147
+ bundle exec rake test:trilogy
148
+ bundle exec rake test:janus_trilogy
149
+
136
150
  lint:
137
151
  runs-on: ubuntu-latest
138
152
  env:
139
153
  AR_VERSION: '7.0'
140
154
  steps:
141
155
  - uses: actions/checkout@v4
156
+ - name: Install SQLite3 Development Library
157
+ run: |
158
+ sudo apt-get update
159
+ sudo apt-get install libsqlite3-dev
142
160
  - uses: ruby/setup-ruby@v1
143
161
  with:
144
- ruby-version: 2.7
162
+ ruby-version: 3.0
145
163
  bundler-cache: true
146
164
  - name: Run Rubocop
147
165
  run: bundle exec rubocop
data/.rubocop.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
+ AllCops:
4
+ TargetRubyVersion: 3.0.x
5
+
3
6
  Metrics/AbcSize:
4
7
  Enabled: false
5
8
 
@@ -12,9 +15,6 @@ Metrics/ClassLength:
12
15
  Metrics/CyclomaticComplexity:
13
16
  Enabled: false
14
17
 
15
- Metrics/LineLength:
16
- Enabled: false
17
-
18
18
  Metrics/MethodLength:
19
19
  Enabled: false
20
20
 
@@ -90,6 +90,9 @@ Layout/SpaceInsideParens:
90
90
  Layout/SpaceInsidePercentLiteralDelimiters:
91
91
  Enabled: false
92
92
 
93
+ Layout/LineLength:
94
+ Enabled: false
95
+
93
96
  Lint/ErbNewArguments:
94
97
  Enabled: false
95
98
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,38 @@
1
+ ## Changes in 2.2.0
2
+
3
+ ### New Features
4
+
5
+ * Add Support for Janus ActiveRecord adapters. Thanks to @permidon via #\873.
6
+
7
+ ## Changes in 2.1.0
8
+
9
+ ### New Features
10
+
11
+ * Add Support for `active_record_proxy_adapters` gem thanks to @stingrayzboy via #\867.
12
+ Since Rails 7.1 makara no longer works and it is not currently maintained. The @nasdaq team
13
+ have written a gem called [active_record_proxy_adapters](https://rubygems.org/gems/active_record_proxy_adapters)
14
+ that implements some makara functionality.
15
+
16
+ ## Changes in 2.0.0
17
+
18
+ ### Breaking Changes
19
+
20
+ * Fix `recursive_on_duplicate_key_update` doesn't work with non-standard
21
+ association name. Thanks to @jacob-carlborg-apoex via \#852. The documentation for the
22
+ `:recursive_on_duplicate_key_update` option specifies that the hash key is
23
+ the association name. But previously the name of associated table was used to
24
+ look up the options. Now the behavior matches the documentation and the name
25
+ of the association is used instead. This only affects associations that uses
26
+ a name that doesn't follow the ActiveRecord naming conventions of
27
+ associations and class names, i.e. when the `class_name:` option is used on
28
+ an association.
29
+
30
+ ## Changes in 1.8.1
31
+
32
+ ### Fixes
33
+
34
+ * Further update for ActiveRecord 7.2 compatibility when running validations. Thanks to @denisahearn via \##847.
35
+
1
36
  ## Changes in 1.8.0
2
37
 
3
38
  ### New Features
data/Gemfile CHANGED
@@ -6,13 +6,15 @@ gemspec
6
6
 
7
7
  version = ENV['AR_VERSION'].to_f
8
8
 
9
- mysql2_version = '0.3.0'
10
- mysql2_version = '0.4.0' if version >= 4.2
9
+ mysql2_version = '0.4.0'
11
10
  mysql2_version = '0.5.0' if version >= 6.1
11
+ mysql2_version = '0.5.6' if version >= 8.0
12
12
  sqlite3_version = '1.3.0'
13
13
  sqlite3_version = '1.4.0' if version >= 6.0
14
+ sqlite3_version = '2.2.0' if version >= 8.0
14
15
  pg_version = '0.9'
15
16
  pg_version = '1.1' if version >= 6.1
17
+ pg_version = '1.5' if version >= 8.0
16
18
 
17
19
  group :development, :test do
18
20
  gem 'rubocop'
@@ -51,19 +53,11 @@ gem "chronic"
51
53
  gem "mocha", "~> 2.1.0"
52
54
 
53
55
  # Debugging
54
- platforms :jruby do
55
- gem "ruby-debug", "= 0.10.4"
56
- end
57
-
58
56
  platforms :ruby do
59
57
  gem "pry-byebug"
60
58
  gem "pry", "~> 0.14.0"
61
59
  end
62
60
 
63
- if version >= 4.0
64
- gem "minitest"
65
- else
66
- gem "test-unit"
67
- end
61
+ gem "minitest"
68
62
 
69
63
  eval_gemfile File.expand_path("../gemfiles/#{version}.gemfile", __FILE__)
data/README.markdown CHANGED
@@ -569,11 +569,11 @@ require 'activerecord-import'
569
569
  ### Load Path Setup
570
570
  To understand how rubygems loads code you can reference the following:
571
571
 
572
- http://guides.rubygems.org/patterns/#loading-code
572
+ https://guides.rubygems.org/patterns/#loading-code
573
573
 
574
574
  And an example of how active_record dynamically load adapters:
575
575
 
576
- https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/connection_specification.rb
576
+ https://github.com/rails/rails/blob/main/activerecord/lib/active_record/connection_adapters.rb
577
577
 
578
578
  In summary, when a gem is loaded rubygems adds the `lib` folder of the gem to the global load path `$LOAD_PATH` so that all `require` lookups will not propagate through all of the folders on the load path. When a `require` is issued each folder on the `$LOAD_PATH` is checked for the file and/or folder referenced. This allows a gem (like activerecord-import) to define push the activerecord-import folder (or namespace) on the `$LOAD_PATH` and any adapters provided by activerecord-import will be found by rubygems when the require is issued.
579
579
 
data/Rakefile CHANGED
@@ -19,17 +19,21 @@ ADAPTERS = %w(
19
19
  mysql2
20
20
  mysql2_makara
21
21
  mysql2spatial
22
+ mysql2_proxy
23
+ janus_mysql2
22
24
  jdbcmysql
23
25
  jdbcsqlite3
24
26
  jdbcpostgresql
25
27
  postgresql
26
28
  postgresql_makara
29
+ postgresql_proxy
27
30
  postgis
28
31
  makara_postgis
29
32
  sqlite3
30
33
  spatialite
31
34
  seamless_database_pool
32
35
  trilogy
36
+ janus_trilogy
33
37
  ).freeze
34
38
  ADAPTERS.each do |adapter|
35
39
  namespace :test do
@@ -44,8 +44,6 @@ require adapter_schema if File.exist?(adapter_schema)
44
44
  Dir["#{File.dirname(__FILE__)}/models/*.rb"].sort.each { |file| require file }
45
45
 
46
46
  require File.join( benchmark_dir, 'lib', "#{options.adapter}_benchmark" )
47
-
48
- table_types = nil
49
47
  table_types = if options.benchmark_all_types
50
48
  ["all"]
51
49
  else
@@ -16,7 +16,7 @@ class BenchmarkBase
16
16
  end
17
17
  end
18
18
 
19
- # Returns an OpenStruct which contains two attritues, +description+ and +tms+ after performing an
19
+ # Returns a struct which contains two attritues, +description+ and +tms+ after performing an
20
20
  # actual benchmark.
21
21
  #
22
22
  # == PARAMETERS
@@ -24,9 +24,12 @@ class BenchmarkBase
24
24
  # * blk - the block of code to benchmark
25
25
  #
26
26
  # == RETURNS
27
- # An OpenStruct object with the following attributes:
27
+ # A struct object with the following attributes:
28
28
  # * description - the description of the benchmark ran
29
29
  # * tms - a Benchmark::Tms containing the results of the benchmark
30
+
31
+ BmStruct = Struct.new( :description, :tms, :failed, keyword_init: true )
32
+
30
33
  def bm( description, &block )
31
34
  tms = nil
32
35
  puts "Benchmarking #{description}"
@@ -35,7 +38,7 @@ class BenchmarkBase
35
38
  delete_all
36
39
  failed = false
37
40
 
38
- OpenStruct.new description: description, tms: tms, failed: failed
41
+ BmStruct.new( description: description, tms: tms, failed: failed )
39
42
  end
40
43
 
41
44
  # Given a model class (ie: Topic), and an array of columns and value sets
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'optparse'
4
- require 'ostruct'
5
4
 
6
5
  #
7
6
  # == PARAMETERS
@@ -10,7 +9,7 @@ require 'ostruct'
10
9
  # * t - the table types to test. ie: myisam, innodb, memory, temporary, etc.
11
10
  #
12
11
  module BenchmarkOptionParser
13
- BANNER = "Usage: ruby #{$0} [options]\nSee ruby #{$0} -h for more options."
12
+ BANNER = "Usage: ruby #{$0} [options]\nSee ruby #{$0} -h for more options.".freeze
14
13
 
15
14
  def self.print_banner
16
15
  puts BANNER
@@ -38,8 +37,11 @@ module BenchmarkOptionParser
38
37
  end
39
38
  end
40
39
 
40
+ OptionsStruct = Struct.new( :adapter, :table_types, :delete_on_finish, :number_of_objects, :outputs,
41
+ :benchmark_all_types, keyword_init: true )
42
+ OutputStruct = Struct.new( :format, :filename, keyword_init: true )
41
43
  def self.parse( args )
42
- options = OpenStruct.new(
44
+ options = OptionsStruct.new(
43
45
  adapter: 'mysql2',
44
46
  table_types: {},
45
47
  delete_on_finish: true,
@@ -81,12 +83,12 @@ module BenchmarkOptionParser
81
83
 
82
84
  # print results in CSV format
83
85
  opts.on( "--to-csv [String]", "Print results in a CSV file format" ) do |filename|
84
- options.outputs << OpenStruct.new( format: 'csv', filename: filename)
86
+ options.outputs << OutputStruct.new( format: 'csv', filename: filename)
85
87
  end
86
88
 
87
89
  # print results in HTML format
88
90
  opts.on( "--to-html [String]", "Print results in HTML format" ) do |filename|
89
- options.outputs << OpenStruct.new( format: 'html', filename: filename )
91
+ options.outputs << OutputStruct.new( format: 'html', filename: filename )
90
92
  end
91
93
  end # end opt.parse!
92
94
 
@@ -100,7 +102,7 @@ module BenchmarkOptionParser
100
102
  end
101
103
 
102
104
  options.number_of_objects = [1000] if options.number_of_objects.empty?
103
- options.outputs = [OpenStruct.new( format: 'html', filename: 'benchmark.html')] if options.outputs.empty?
105
+ options.outputs = [OutputStruct.new( format: 'html', filename: 'benchmark.html')] if options.outputs.empty?
104
106
 
105
107
  print_options( options )
106
108
 
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ gem 'activerecord', '~> 8.0.0'
@@ -58,7 +58,7 @@ module ActiveRecord::Import::SQLite3Adapter
58
58
  sql = []
59
59
 
60
60
  # Options :recursive and :on_duplicate_key_ignore are mutually exclusive
61
- if supports_on_duplicate_key_update? && ((options[:ignore] || options[:on_duplicate_key_ignore]) && !options[:on_duplicate_key_update])
61
+ if supports_on_duplicate_key_update? && (options[:ignore] || options[:on_duplicate_key_ignore]) && !options[:on_duplicate_key_update]
62
62
  sql << sql_for_on_duplicate_key_ignore( options[:on_duplicate_key_ignore] )
63
63
  end
64
64
 
@@ -11,11 +11,15 @@ module ActiveRecord::Import
11
11
  case adapter
12
12
  when 'mysql2_makara' then 'mysql2'
13
13
  when 'mysql2spatial' then 'mysql2'
14
+ when 'mysql2_proxy' then 'mysql2'
15
+ when 'janus_mysql2' then 'mysql2'
14
16
  when 'spatialite' then 'sqlite3'
15
17
  when 'postgresql_makara' then 'postgresql'
18
+ when 'postgresql_proxy' then 'postgresql'
16
19
  when 'makara_postgis' then 'postgresql'
17
20
  when 'postgis' then 'postgresql'
18
21
  when 'cockroachdb' then 'postgresql'
22
+ when 'janus_trilogy' then 'trilogy'
19
23
  else adapter
20
24
  end
21
25
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "ostruct"
4
-
5
3
  module ActiveRecord::Import::ConnectionAdapters; end
6
4
 
7
5
  module ActiveRecord::Import # :nodoc:
@@ -94,7 +92,7 @@ module ActiveRecord::Import # :nodoc:
94
92
  env = ActiveSupport::Callbacks::Filters::Environment.new(model, false, nil)
95
93
  if runner.respond_to?(:call) # ActiveRecord < 5.1
96
94
  runner.call(env)
97
- else # ActiveRecord 5.1
95
+ else # ActiveRecord >= 5.1
98
96
  # Note that this is a gross simplification of ActiveSupport::Callbacks#run_callbacks.
99
97
  # It's technically possible for there to exist an "around" callback in the
100
98
  # :validate chain, but this would be an aberration, since Rails doesn't define
@@ -107,7 +105,8 @@ module ActiveRecord::Import # :nodoc:
107
105
  # no real-world use case for it.
108
106
  raise "The :validate callback chain contains an 'around' callback, which is unsupported" unless runner.final?
109
107
  runner.invoke_before(env)
110
- runner.invoke_after(env)
108
+ # Ensure a truthy value is returned. ActiveRecord < 7.2 always returned an array.
109
+ runner.invoke_after(env) || []
111
110
  end
112
111
  elsif @validate_callbacks.method(:compile).arity == 0 # ActiveRecord = 4.0
113
112
  model.instance_eval @validate_callbacks.compile
@@ -560,7 +559,7 @@ class ActiveRecord::Base
560
559
  options[:primary_key] = primary_key
561
560
  options[:locking_column] = locking_column if locking_enabled?
562
561
 
563
- is_validating = options[:validate_with_context].present? ? true : options[:validate]
562
+ is_validating = options[:validate_with_context].present? || options[:validate]
564
563
  validator = ActiveRecord::Import::Validator.new(self, options)
565
564
 
566
565
  # assume array of model objects
@@ -858,12 +857,11 @@ class ActiveRecord::Base
858
857
 
859
858
  private
860
859
 
861
- def associated_options(options, associated_class)
860
+ def associated_options(options, association)
862
861
  return options unless options.key?(:recursive_on_duplicate_key_update)
863
862
 
864
- table_name = associated_class.arel_table.name.to_sym
865
863
  options.merge(
866
- on_duplicate_key_update: options[:recursive_on_duplicate_key_update][table_name]
864
+ on_duplicate_key_update: options[:recursive_on_duplicate_key_update][association]
867
865
  )
868
866
  end
869
867
 
@@ -972,12 +970,12 @@ class ActiveRecord::Base
972
970
  options.delete(:returning)
973
971
 
974
972
  associated_objects_by_class.each_value do |associations|
975
- associations.each_value do |associated_records|
973
+ associations.each do |association, associated_records|
976
974
  next if associated_records.empty?
977
975
 
978
976
  associated_class = associated_records.first.class
979
977
  associated_class.bulk_import(associated_records,
980
- associated_options(options, associated_class))
978
+ associated_options(options, association))
981
979
  end
982
980
  end
983
981
  end
@@ -1134,8 +1132,6 @@ When importing an array of hashes with provided columns_names, each hash must co
1134
1132
 
1135
1133
  Required keys: #{required_keys}
1136
1134
  Missing keys: #{missing_keys}
1137
-
1138
- Hash: #{hash}
1139
1135
  EOS
1140
1136
  else
1141
1137
  <<-EOS
@@ -1148,8 +1144,6 @@ for the missing keys or group these records into batches by key set before impor
1148
1144
  Required keys: #{required_keys}
1149
1145
  Extra keys: #{extra_keys}
1150
1146
  Missing keys: #{missing_keys}
1151
-
1152
- Hash: #{hash}
1153
1147
  EOS
1154
1148
  end
1155
1149
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module Import
5
- VERSION = "1.8.0"
5
+ VERSION = "2.2.0"
6
6
  end
7
7
  end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV["ARE_DB"] = "mysql2"
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+
5
+ ENV["ARE_DB"] = "trilogy"
6
+
7
+ if ENV['AR_VERSION'].to_f <= 7.0
8
+ require "activerecord-trilogy-adapter"
9
+ require "trilogy_adapter/connection"
10
+ ActiveRecord::Base.extend TrilogyAdapter::Connection
11
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV["ARE_DB"] = "mysql2"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV["ARE_DB"] = "postgresql"
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'logger'
4
+
3
5
  ENV["ARE_DB"] = "trilogy"
4
6
 
5
7
  if ENV['AR_VERSION'].to_f <= 7.0
@@ -16,6 +16,12 @@ mysql2spatial:
16
16
  mysql2_makara:
17
17
  <<: *mysql2
18
18
 
19
+ mysql2_proxy:
20
+ <<: *mysql2
21
+
22
+ janus_mysql2:
23
+ <<: *mysql2
24
+
19
25
  postgresql: &postgresql
20
26
  <<: *common
21
27
  username: postgres
@@ -26,6 +32,9 @@ postgresql: &postgresql
26
32
  postresql_makara:
27
33
  <<: *postgresql
28
34
 
35
+ postresql_proxy:
36
+ <<: *postgresql
37
+
29
38
  postgis:
30
39
  <<: *postgresql
31
40
 
@@ -57,3 +66,8 @@ trilogy:
57
66
  <<: *common
58
67
  adapter: trilogy
59
68
  host: mysql
69
+
70
+ janus_trilogy:
71
+ <<: *common
72
+ adapter: trilogy
73
+ host: mysql
@@ -3,7 +3,7 @@ common: &common
3
3
  password: root
4
4
  encoding: utf8
5
5
  collation: utf8_general_ci
6
- host: localhost
6
+ host: 127.0.0.1
7
7
  database: activerecord_import_test
8
8
 
9
9
  jdbcpostgresql: &postgresql
@@ -30,6 +30,12 @@ mysql2spatial:
30
30
  mysql2_makara:
31
31
  <<: *mysql2
32
32
 
33
+ mysql2_proxy:
34
+ <<: *mysql2
35
+
36
+ janus_mysql2:
37
+ <<: *mysql2
38
+
33
39
  oracle:
34
40
  <<: *common
35
41
  adapter: oracle
@@ -45,6 +51,9 @@ postgresql: &postgresql
45
51
  postresql_makara:
46
52
  <<: *postgresql
47
53
 
54
+ postresql_proxy:
55
+ <<: *postgresql
56
+
48
57
  postgis:
49
58
  <<: *postgresql
50
59
 
@@ -54,7 +63,7 @@ seamless_database_pool:
54
63
  pool_adapter: mysql2
55
64
  prepared_statements: false
56
65
  master:
57
- host: localhost
66
+ host: 127.0.0.1
58
67
 
59
68
  sqlite:
60
69
  adapter: sqlite
@@ -70,3 +79,7 @@ spatialite:
70
79
  trilogy:
71
80
  <<: *common
72
81
  adapter: trilogy
82
+
83
+ janus_trilogy:
84
+ <<: *common
85
+ adapter: trilogy
data/test/import_test.rb CHANGED
@@ -741,14 +741,8 @@ describe "#import" do
741
741
  ]
742
742
  Book.import books
743
743
  assert_equal 2, Book.count
744
-
745
- if ENV['AR_VERSION'].to_i >= 5.0
746
- assert_equal 'draft', Book.first.read_attribute('status')
747
- assert_equal 'published', Book.last.read_attribute('status')
748
- else
749
- assert_equal 0, Book.first.read_attribute('status')
750
- assert_equal 1, Book.last.read_attribute('status')
751
- end
744
+ assert_equal 'draft', Book.first.read_attribute('status')
745
+ assert_equal 'published', Book.last.read_attribute('status')
752
746
  end
753
747
 
754
748
  it 'should be able to import enum fields with default value' do
@@ -758,32 +752,19 @@ describe "#import" do
758
752
  ]
759
753
  Book.import books
760
754
  assert_equal 1, Book.count
761
-
762
- if ENV['AR_VERSION'].to_i >= 5.0
763
- assert_equal 'draft', Book.first.read_attribute('status')
764
- else
765
- assert_equal 0, Book.first.read_attribute('status')
766
- end
755
+ assert_equal 'draft', Book.first.read_attribute('status')
767
756
  end
768
757
 
769
- if ENV['AR_VERSION'].to_f > 4.1
770
- it 'should be able to import enum fields by name' do
771
- Book.delete_all if Book.count > 0
772
- books = [
773
- Book.new(author_name: "Foo", title: "Baz", status: :draft),
774
- Book.new(author_name: "Foo2", title: "Baz2", status: :published),
775
- ]
776
- Book.import books
777
- assert_equal 2, Book.count
778
-
779
- if ENV['AR_VERSION'].to_i >= 5.0
780
- assert_equal 'draft', Book.first.read_attribute('status')
781
- assert_equal 'published', Book.last.read_attribute('status')
782
- else
783
- assert_equal 0, Book.first.read_attribute('status')
784
- assert_equal 1, Book.last.read_attribute('status')
785
- end
786
- end
758
+ it 'should be able to import enum fields by name' do
759
+ Book.delete_all if Book.count > 0
760
+ books = [
761
+ Book.new(author_name: "Foo", title: "Baz", status: :draft),
762
+ Book.new(author_name: "Foo2", title: "Baz2", status: :published),
763
+ ]
764
+ Book.import books
765
+ assert_equal 2, Book.count
766
+ assert_equal 'draft', Book.first.read_attribute('status')
767
+ assert_equal 'published', Book.last.read_attribute('status')
787
768
  end
788
769
  end
789
770
 
@@ -796,13 +777,8 @@ describe "#import" do
796
777
  Book.import columns, values
797
778
  assert_equal 2, Book.count
798
779
 
799
- if ENV['AR_VERSION'].to_i >= 5.0
800
- assert_equal 'draft', Book.first.read_attribute('status')
801
- assert_equal 'published', Book.last.read_attribute('status')
802
- else
803
- assert_equal 0, Book.first.read_attribute('status')
804
- assert_equal 1, Book.last.read_attribute('status')
805
- end
780
+ assert_equal 'draft', Book.first.read_attribute('status')
781
+ assert_equal 'published', Book.last.read_attribute('status')
806
782
  end
807
783
  end
808
784