activerecord-import 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 866dd09466fbda981329e13916e89986cb47d65259f0889b8a3b53aeca1aee32
4
- data.tar.gz: 258a0d2fc34bbb928500e2f8a83df4f5bdc8901c25e2e123a569c56d587d3f53
3
+ metadata.gz: f8b122b955b4a926db451a6a3ef72405ade6d69b54876bccb9ea51680486b328
4
+ data.tar.gz: 3af5c65f25ffb54d338d012aab4f3608513071287c8a759f3ba678850a81f6e0
5
5
  SHA512:
6
- metadata.gz: 989562e1fb64d669a96211c6b80df5b89d8a43aa38575ec6706d0633b405983a63849bd5fb78d4031ed7e4b2c239192f62d4b3d9e720f4c474cd3801600d11ef
7
- data.tar.gz: 22e6ccbb750bb7851930d98c2b90f496c759d35503c8c1e58b841f4a928a283c486caec3f22cb57e6948b6960e6fff2a598499f0670f59b281e321dded20c183
6
+ metadata.gz: 638f6a8062713b07b1c2ebe866fa647c254d42e594c0fa056b5a710bcd9a2560b2217db73a89f5804c9fc1a71d5de05fc98625771e6225e9e148f58048618079
7
+ data.tar.gz: 806d66d95034276b0daec9c6c207b8a6187ec0950a44b312267aeef4d491b1c9f5e036641df35950296180f124315fc220e9af5d5b4d4057278176dcf667b1c3
@@ -22,11 +22,16 @@ jobs:
22
22
  ruby:
23
23
  - 3.2
24
24
  env:
25
+ - AR_VERSION: '7.1'
26
+ RUBYOPT: --enable-frozen-string-literal
25
27
  - AR_VERSION: '7.0'
26
28
  RUBYOPT: --enable-frozen-string-literal
27
29
  - AR_VERSION: 6.1
28
30
  RUBYOPT: --enable-frozen-string-literal
29
31
  include:
32
+ - ruby: 3.1
33
+ env:
34
+ AR_VERSION: '7.1'
30
35
  - ruby: 3.1
31
36
  env:
32
37
  AR_VERSION: '7.0'
@@ -39,6 +44,9 @@ jobs:
39
44
  - ruby: '3.0'
40
45
  env:
41
46
  AR_VERSION: 6.1
47
+ - ruby: jruby
48
+ env:
49
+ AR_VERSION: '7.0'
42
50
  - ruby: 2.7
43
51
  env:
44
52
  AR_VERSION: '7.0'
@@ -48,6 +56,9 @@ jobs:
48
56
  - ruby: 2.7
49
57
  env:
50
58
  AR_VERSION: '6.0'
59
+ - ruby: jruby-9.3.10.0
60
+ env:
61
+ AR_VERSION: '6.1'
51
62
  - ruby: 2.6
52
63
  env:
53
64
  AR_VERSION: 5.2
@@ -65,7 +76,7 @@ jobs:
65
76
  AR_VERSION: ${{ matrix.env.AR_VERSION }}
66
77
  DB_DATABASE: activerecord_import_test
67
78
  steps:
68
- - uses: actions/checkout@v2
79
+ - uses: actions/checkout@v4
69
80
  - uses: ruby/setup-ruby@v1
70
81
  with:
71
82
  ruby-version: ${{ matrix.ruby }}
@@ -104,7 +115,7 @@ jobs:
104
115
  env:
105
116
  AR_VERSION: '7.0'
106
117
  steps:
107
- - uses: actions/checkout@v2
118
+ - uses: actions/checkout@v4
108
119
  - uses: ruby/setup-ruby@v1
109
120
  with:
110
121
  ruby-version: 2.7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## Changes in 1.5.1
2
+
3
+ ### Fixes
4
+
5
+ * Stop memoizing schema_columns_hash so dynamic schema changes are picked up. Thanks to @koshigoe via \##812.
6
+
1
7
  ## Changes in 1.5.0
2
8
 
3
9
  ### New Features
data/Dockerfile ADDED
@@ -0,0 +1,23 @@
1
+ # Use the official Ruby 3.2 image as a base image
2
+ ARG RUBY_VERSION=3.2
3
+ FROM ruby:${RUBY_VERSION}-bullseye
4
+
5
+ # Set the working directory
6
+ WORKDIR /usr/src/app
7
+
8
+ # Install system packages
9
+ RUN apt-get update -qq && \
10
+ apt-get install -y default-mysql-client postgresql postgresql-contrib vim && \
11
+ apt-get clean
12
+
13
+ # Set environment variables
14
+ ENV AR_VERSION=7.0
15
+
16
+ # Copy all files
17
+ COPY . .
18
+
19
+ # Move sample database.yml and install gems
20
+ RUN mv test/database.yml.sample test/database.yml && \
21
+ bundle install
22
+
23
+ CMD ["irb"]
data/Gemfile CHANGED
@@ -31,9 +31,9 @@ end
31
31
  platforms :jruby do
32
32
  gem "jdbc-mysql"
33
33
  gem "jdbc-postgres"
34
- gem "activerecord-jdbcsqlite3-adapter", "~> 1.3"
35
- gem "activerecord-jdbcmysql-adapter", "~> 1.3"
36
- gem "activerecord-jdbcpostgresql-adapter", "~> 1.3"
34
+ gem "activerecord-jdbcsqlite3-adapter"
35
+ gem "activerecord-jdbcmysql-adapter"
36
+ gem "activerecord-jdbcpostgresql-adapter"
37
37
  end
38
38
 
39
39
  # Support libs
data/README.markdown CHANGED
@@ -626,6 +626,19 @@ AR_VERSION=7.0 bundle exec rake test:postgresql test:sqlite3 test:mysql2
626
626
 
627
627
  Once you have pushed up your changes, you can find your CI results [here](https://github.com/zdennis/activerecord-import/actions).
628
628
 
629
+ #### Docker Setup
630
+
631
+ Before you begin, make sure you have [Docker](https://www.docker.com/products/docker-desktop/) and [Docker Compose](https://docs.docker.com/compose/) installed on your machine. If you don't, you can install both via Homebrew using the following command:
632
+
633
+ ```bash
634
+ brew install docker && brew install docker-compose
635
+ ```
636
+ ##### Steps
637
+
638
+ 1. In your terminal run `docker-compose up --build`
639
+ 1. In another tab/window run `docker-compose exec app bash`
640
+ 1. In that same terminal run the mysql2 test by running `bundle exec rake test:mysql2`
641
+
629
642
  ## Issue Triage [![Open Source Helpers](https://www.codetriage.com/zdennis/activerecord-import/badges/users.svg)](https://www.codetriage.com/zdennis/activerecord-import)
630
643
 
631
644
  You can triage issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to activerecord-import on CodeTriage](https://www.codetriage.com/zdennis/activerecord-import).
@@ -0,0 +1,34 @@
1
+ version: "3.5"
2
+
3
+ services:
4
+ mysql:
5
+ platform: linux/x86_64
6
+ image: mysql:5.7
7
+ volumes:
8
+ - mysql-data:/var/lib/mysql
9
+ ports:
10
+ - "3306:3306"
11
+
12
+ postgresql:
13
+ image: postgres:latest
14
+ volumes:
15
+ - postgresql-data:/var/lib/postgresql/data
16
+ ports:
17
+ - "5432:5432"
18
+
19
+ app:
20
+ build:
21
+ context: .
22
+ environment:
23
+ DB_HOST: mysql
24
+ AR_VERSION: 7.0
25
+ volumes:
26
+ - .:/usr/src/app
27
+ depends_on:
28
+ - mysql
29
+ - postgresql
30
+ command: tail -f /dev/null
31
+
32
+ volumes:
33
+ mysql-data:
34
+ postgresql-data:
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ gem 'activerecord', '~> 7.1.0'
@@ -969,7 +969,7 @@ class ActiveRecord::Base
969
969
  end
970
970
 
971
971
  def schema_columns_hash
972
- @schema_columns_hash ||= if respond_to?(:ignored_columns) && ignored_columns.any?
972
+ if respond_to?(:ignored_columns) && ignored_columns.any?
973
973
  connection.schema_cache.columns_hash(table_name)
974
974
  else
975
975
  columns_hash
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module Import
5
- VERSION = "1.5.0"
5
+ VERSION = "1.5.1"
6
6
  end
7
7
  end
@@ -8,6 +8,7 @@ common: &common
8
8
  mysql2: &mysql2
9
9
  <<: *common
10
10
  adapter: mysql2
11
+ host: mysql
11
12
 
12
13
  mysql2spatial:
13
14
  <<: *mysql2
@@ -19,6 +20,7 @@ postgresql: &postgresql
19
20
  <<: *common
20
21
  username: postgres
21
22
  adapter: postgresql
23
+ host: postgresql
22
24
  min_messages: warning
23
25
 
24
26
  postresql_makara:
data/test/models/book.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  class Book < ActiveRecord::Base
4
4
  belongs_to :topic, inverse_of: :books
5
- belongs_to :tag, foreign_key: [:tag_id, :parent_id]
5
+ belongs_to :tag, foreign_key: [:tag_id, :parent_id] unless ENV["SKIP_COMPOSITE_PK"]
6
6
 
7
7
  has_many :chapters, inverse_of: :book
8
8
  has_many :discounts, as: :discountable
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Customer < ActiveRecord::Base
4
- has_many :orders,
5
- inverse_of: :customer,
6
- primary_key: %i(account_id id),
7
- foreign_key: %i(account_id customer_id)
4
+ unless ENV["SKIP_COMPOSITE_PK"]
5
+ has_many :orders,
6
+ inverse_of: :customer,
7
+ primary_key: %i(account_id id),
8
+ foreign_key: %i(account_id customer_id)
9
+ end
8
10
  end
data/test/models/order.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Order < ActiveRecord::Base
4
- belongs_to :customer,
5
- inverse_of: :orders,
6
- primary_key: %i(account_id id),
7
- foreign_key: %i(account_id customer_id)
4
+ unless ENV["SKIP_COMPOSITE_PK"]
5
+ belongs_to :customer,
6
+ inverse_of: :orders,
7
+ primary_key: %i(account_id id),
8
+ foreign_key: %i(account_id customer_id)
9
+ end
8
10
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TagAlias < ActiveRecord::Base
4
- belongs_to :tag, foreign_key: [:tag_id, :parent_id], required: true
4
+ unless ENV["SKIP_COMPOSITE_PK"]
5
+ belongs_to :tag, foreign_key: [:tag_id, :parent_id], required: true
6
+ end
5
7
  end
@@ -2,8 +2,10 @@
2
2
 
3
3
  ActiveRecord::Schema.define do
4
4
  create_table :schema_info, force: :cascade do |t|
5
- t.integer :version, unique: true
5
+ t.integer :version
6
6
  end
7
+ add_index :schema_info, :version, unique: true
8
+
7
9
  SchemaInfo.create version: SchemaInfo::VERSION
8
10
 
9
11
  create_table :group, force: :cascade do |t|
@@ -8,10 +8,7 @@ ActiveRecord::Schema.define do
8
8
  # create ENUM if it does not exist yet
9
9
  begin
10
10
  execute('CREATE TYPE vendor_type AS ENUM (\'wholesaler\', \'retailer\');')
11
- rescue ActiveRecord::StatementInvalid => e
12
- # since PostgreSQL does not support IF NOT EXISTS when creating a TYPE,
13
- # rescue the error and check the error class
14
- raise unless e.cause.is_a? PG::DuplicateObject
11
+ rescue ActiveRecord::StatementInvalid
15
12
  execute('ALTER TYPE vendor_type ADD VALUE IF NOT EXISTS \'wholesaler\';')
16
13
  execute('ALTER TYPE vendor_type ADD VALUE IF NOT EXISTS \'retailer\';')
17
14
  end
@@ -147,7 +147,7 @@ def should_support_recursive_import
147
147
  end
148
148
 
149
149
  books.each do |book|
150
- assert_equal book.topic_id, nil
150
+ assert_nil book.topic_id, nil
151
151
  end
152
152
  end
153
153
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-import
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Dennis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-21 00:00:00.000000000 Z
11
+ date: 2023-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -51,6 +51,7 @@ files:
51
51
  - ".rubocop_todo.yml"
52
52
  - Brewfile
53
53
  - CHANGELOG.md
54
+ - Dockerfile
54
55
  - Gemfile
55
56
  - LICENSE
56
57
  - README.markdown
@@ -68,6 +69,7 @@ files:
68
69
  - benchmarks/models/test_memory.rb
69
70
  - benchmarks/models/test_myisam.rb
70
71
  - benchmarks/schema/mysql2_schema.rb
72
+ - docker-compose.yml
71
73
  - gemfiles/4.2.gemfile
72
74
  - gemfiles/5.0.gemfile
73
75
  - gemfiles/5.1.gemfile
@@ -75,6 +77,7 @@ files:
75
77
  - gemfiles/6.0.gemfile
76
78
  - gemfiles/6.1.gemfile
77
79
  - gemfiles/7.0.gemfile
80
+ - gemfiles/7.1.gemfile
78
81
  - lib/activerecord-import.rb
79
82
  - lib/activerecord-import/active_record/adapters/abstract_adapter.rb
80
83
  - lib/activerecord-import/active_record/adapters/jdbcmysql_adapter.rb
@@ -175,7 +178,7 @@ homepage: https://github.com/zdennis/activerecord-import
175
178
  licenses:
176
179
  - MIT
177
180
  metadata: {}
178
- post_install_message:
181
+ post_install_message:
179
182
  rdoc_options: []
180
183
  require_paths:
181
184
  - lib
@@ -190,8 +193,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
193
  - !ruby/object:Gem::Version
191
194
  version: '0'
192
195
  requirements: []
193
- rubygems_version: 3.0.3.1
194
- signing_key:
196
+ rubygems_version: 3.3.25
197
+ signing_key:
195
198
  specification_version: 4
196
199
  summary: Bulk insert extension for ActiveRecord
197
200
  test_files: