activerecord-virtual_attributes 7.0.0 → 7.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf8f363320713146ad286d76999f5640a9fc44f3e139f6e5377ac8220e476217
4
- data.tar.gz: cbabad277bfef0e01da4d14b8942671770eb283c9692ef9eb7a07cbac5f25b68
3
+ metadata.gz: e4a4b9dd1a4f51cfef16c50545afe8c064f1727a4580016b400b78afe4279a15
4
+ data.tar.gz: 8a4c28698b8191586fb25dfe0885b54300306ac2f5a3866e7731bc789bd85654
5
5
  SHA512:
6
- metadata.gz: 10295799b997217903b155c7ed84e9ee82bad2cf6c208b6aa140dc94e66df9b4ed8fbcf13418a2feadf075e7f93b2c550d7a94b698aae0c08b6d29a4d5ebe159
7
- data.tar.gz: 1663fd7ab8af93e3419b6a1ae608c94d55df957b45d904e38b31a3b5f93667159e6ee10e667f560174b12cc2b66e936e20bcadc4ac98a45953ed3923f21cac94
6
+ metadata.gz: 0b06ebb3ad544e2c19f4b0a103ec54cd471fa9a187cee566399b985446244baadac66d35a343dc7311b7b73963bb55a15d87a3968287ea434f1093595073c974
7
+ data.tar.gz: e904ebef2e7594f37055971d738a20343c546834ec7597d10816949a005f1ba6dbd979cc422b1ba1b99a079e699c9219b97907e798d9eee5e3fbfa7ce114e1f6
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ The versioning of this gem follows ActiveRecord versioning, and does not follow
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [7.1.0] - 2025-02-19
8
+
9
+ * Use TableAlias for table aliasing [#168](https://github.com/ManageIQ/activerecord-virtual_attributes/pull/168)
10
+ * Rails 7.1 support
11
+
7
12
  ## [7.0.0] - 2024-08-01
8
13
 
9
14
  * Use Arel.literal [#154](https://github.com/ManageIQ/activerecord-virtual_attributes/pull/154)
@@ -106,7 +111,8 @@ The versioning of this gem follows ActiveRecord versioning, and does not follow
106
111
  * Initial Release
107
112
  * Extracted from ManageIQ/manageiq
108
113
 
109
- [Unreleased]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v7.0.0...HEAD
114
+ [Unreleased]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v7.1.0...HEAD
115
+ [7.1.0]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v7.0.0...v7.1.0
110
116
  [7.0.0]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v6.1.2...v7.0.0
111
117
  [6.1.2]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v6.1.1...v6.1.2
112
118
  [6.1.1]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v6.1.0...v6.1.1
data/Gemfile CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~>7.0.8"
5
+ gem "activerecord", "~>7.1.5"
6
6
  gem "mysql2"
7
7
  gem "pg"
8
8
  gem "sqlite3", "< 2"
@@ -23,17 +23,19 @@ Gem::Specification.new do |spec|
23
23
  # Specify which files should be added to the gem when it is released.
24
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
25
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|bin)/}) || f.match(/^(\.)|renovate.json/) }
27
27
  end
28
28
 
29
29
  spec.require_paths = ["lib"]
30
30
 
31
- spec.add_runtime_dependency "activerecord", "~> 7.0"
31
+ spec.add_dependency "concurrent-ruby", "< 1.3.5" # Temporary pin down as concurrent-ruby 1.3.5 breaks Rails 7.0, and rails-core doesn't
32
+ # plan to ship a new 7.0 to fix it. See https://github.com/rails/rails/pull/54264
33
+ spec.add_runtime_dependency "activerecord", "~> 7.0", ">=7.0.8.7"
32
34
 
33
35
  spec.add_development_dependency "byebug"
34
36
  spec.add_development_dependency "database_cleaner-active_record", "~> 2.1"
35
37
  spec.add_development_dependency "db-query-matchers"
36
- spec.add_development_dependency "manageiq-style"
38
+ spec.add_development_dependency "manageiq-style", ">= 1.5.3"
37
39
  spec.add_development_dependency "mysql2"
38
40
  spec.add_development_dependency "pg"
39
41
  spec.add_development_dependency "rake", "~> 13.0"
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module VirtualAttributes
3
- VERSION = "7.0.0".freeze
3
+ VERSION = "7.1.0".freeze
4
4
  end
5
5
  end
@@ -271,11 +271,9 @@ module ActiveRecord
271
271
  def self.select_from_alias_table(to_klass, src_relation)
272
272
  to_table = to_klass.arel_table
273
273
  # if a self join, alias the second table to a different name
274
- if to_table.table_name == src_relation.table_name
275
- # use a dup to not modify the primary table in the model
276
- to_table = to_table.dup
274
+ if to_table.name == src_relation.name
277
275
  # use a table alias to not conflict with table name in the primary query
278
- to_table.table_alias = "#{to_table.table_name}_sub"
276
+ to_table = to_table.alias("#{to_table.name}_sub")
279
277
  end
280
278
  to_table
281
279
  end
@@ -159,9 +159,9 @@ module ActiveRecord
159
159
  records_by_assoc.each do |klass_associations, klass_records|
160
160
  next if klass_associations.blank?
161
161
 
162
- Array[klass_associations].each do |klass_association| # rubocop:disable Style/RedundantArrayConstructor
162
+ Array.wrap(klass_associations).each do |klass_association|
163
163
  # this calls back into itself, but it will take the short circuit
164
- Preloader.new(:records => klass_records, :associations => klass_association, :scope => scope).call
164
+ Preloader.new(:records => klass_records, :associations => klass_association, :scope => scope, :available_records => @available_records, :associate_by_default => @associate_by_default).call
165
165
  end
166
166
  end
167
167
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-virtual_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 7.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keenan Brock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-31 00:00:00.000000000 Z
11
+ date: 2025-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: concurrent-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "<"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "<"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.5
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: activerecord
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -17,6 +31,9 @@ dependencies:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
33
  version: '7.0'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 7.0.8.7
20
37
  type: :runtime
21
38
  prerelease: false
22
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +41,9 @@ dependencies:
24
41
  - - "~>"
25
42
  - !ruby/object:Gem::Version
26
43
  version: '7.0'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 7.0.8.7
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: byebug
29
49
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +92,14 @@ dependencies:
72
92
  requirements:
73
93
  - - ">="
74
94
  - !ruby/object:Gem::Version
75
- version: '0'
95
+ version: 1.5.3
76
96
  type: :development
77
97
  prerelease: false
78
98
  version_requirements: !ruby/object:Gem::Requirement
79
99
  requirements:
80
100
  - - ">="
81
101
  - !ruby/object:Gem::Version
82
- version: '0'
102
+ version: 1.5.3
83
103
  - !ruby/object:Gem::Dependency
84
104
  name: mysql2
85
105
  requirement: !ruby/object:Gem::Requirement
@@ -171,23 +191,12 @@ executables: []
171
191
  extensions: []
172
192
  extra_rdoc_files: []
173
193
  files:
174
- - ".codeclimate.yml"
175
- - ".github/workflows/ci.yaml"
176
- - ".gitignore"
177
- - ".rspec"
178
- - ".rubocop.yml"
179
- - ".rubocop_cc.yml"
180
- - ".rubocop_local.yml"
181
- - ".whitesource"
182
- - ".yamllint"
183
194
  - CHANGELOG.md
184
195
  - Gemfile
185
196
  - LICENSE.txt
186
197
  - README.md
187
198
  - Rakefile
188
199
  - activerecord-virtual_attributes.gemspec
189
- - bin/console
190
- - bin/setup
191
200
  - init.rb
192
201
  - lib/active_record-virtual_attributes.rb
193
202
  - lib/active_record/virtual_attributes.rb
@@ -201,8 +210,6 @@ files:
201
210
  - lib/active_record/virtual_attributes/virtual_reflections.rb
202
211
  - lib/active_record/virtual_attributes/virtual_total.rb
203
212
  - lib/activerecord-virtual_attributes.rb
204
- - renovate.json
205
- - seed.rb
206
213
  homepage: https://github.com/ManageIQ/activerecord-virtual_attributes
207
214
  licenses:
208
215
  - Apache 2.0
@@ -226,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
233
  - !ruby/object:Gem::Version
227
234
  version: '0'
228
235
  requirements: []
229
- rubygems_version: 3.5.9
236
+ rubygems_version: 3.5.22
230
237
  signing_key:
231
238
  specification_version: 4
232
239
  summary: Access non-sql attributes from sql
data/.codeclimate.yml DELETED
@@ -1,34 +0,0 @@
1
- version: '2'
2
- prepare:
3
- fetch:
4
- - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_base.yml
5
- path: ".rubocop_base.yml"
6
- - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/.rubocop_cc_base.yml
7
- path: ".rubocop_cc_base.yml"
8
- - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/base.yml
9
- path: styles/base.yml
10
- - url: https://raw.githubusercontent.com/ManageIQ/manageiq-style/master/styles/cc_base.yml
11
- path: styles/cc_base.yml
12
- checks:
13
- argument-count:
14
- enabled: false
15
- complex-logic:
16
- enabled: false
17
- file-lines:
18
- enabled: false
19
- method-complexity:
20
- config:
21
- threshold: 11
22
- method-count:
23
- enabled: false
24
- method-lines:
25
- enabled: false
26
- nested-control-flow:
27
- enabled: false
28
- return-statements:
29
- enabled: false
30
- plugins:
31
- rubocop:
32
- enabled: true
33
- config: ".rubocop_cc.yml"
34
- channel: rubocop-1-56-3
@@ -1,71 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- pull_request:
6
- schedule:
7
- - cron: '0 0 * * 0'
8
-
9
- jobs:
10
- ci:
11
- runs-on: ubuntu-latest
12
- strategy:
13
- matrix:
14
- ruby-version:
15
- - '2.7'
16
- - '3.0'
17
- - '3.1'
18
- services:
19
- postgres:
20
- image: postgres:13
21
- env:
22
- POSTGRES_PASSWORD: password
23
- POSTGRES_DB: virtual_attributes
24
- options: --health-cmd pg_isready --health-interval 2s --health-timeout 5s --health-retries 5
25
- ports:
26
- - 5432:5432
27
- mysql:
28
- image: mysql:8.4
29
- env:
30
- MYSQL_ROOT_PASSWORD: password
31
- MYSQL_DATABASE: virtual_attributes
32
- options: --health-cmd="mysqladmin ping -h 127.0.0.1 -P 3306 --silent" --health-interval 10s --health-timeout 5s --health-retries 3
33
- ports:
34
- - 3306:3306
35
- env:
36
- CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
37
- # for the pg cli (psql, pg_isready) and rails
38
- PGHOST: localhost
39
- PGPORT: 5432
40
- PGUSER: postgres
41
- PGPASSWORD: password
42
- # for the mysql cli (mysql, mysqladmin)
43
- MYSQL_HOST: 127.0.0.1
44
- MYSQL_PWD: password
45
- steps:
46
- - uses: actions/checkout@v4
47
- - name: Set up Ruby
48
- uses: ruby/setup-ruby@v1
49
- with:
50
- ruby-version: ${{ matrix.ruby-version }}
51
- bundler-cache: true
52
- timeout-minutes: 30
53
- - name: Run SQLite tests
54
- env:
55
- DB: sqlite3
56
- run: bundle exec rake
57
- - name: Run PostgreSQL tests
58
- env:
59
- DB: postgresql
60
- COLLATE_SYMBOLS: false
61
- run: bundle exec rake
62
- - name: Run MySQL tests
63
- env:
64
- DB: mysql2
65
- run: bundle exec rake
66
- - name: Report code coverage
67
- if: ${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '3.1' }}
68
- continue-on-error: true
69
- uses: paambaati/codeclimate-action@v8
70
- env:
71
- CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- test/database.yml
11
- **/*.log
12
- **/*.db
13
- Gemfile.lock
14
- gemfiles/*.lock
15
-
16
- # rspec failure tracking
17
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,4 +0,0 @@
1
- inherit_from:
2
- - ".rubocop_local.yml"
3
- inherit_gem:
4
- manageiq-style: ".rubocop_base.yml"
data/.rubocop_cc.yml DELETED
@@ -1,4 +0,0 @@
1
- inherit_from:
2
- - ".rubocop_base.yml"
3
- - ".rubocop_cc_base.yml"
4
- - ".rubocop_local.yml"
data/.rubocop_local.yml DELETED
File without changes
data/.whitesource DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "settingsInheritedFrom": "ManageIQ/whitesource-config@master"
3
- }
data/.yamllint DELETED
@@ -1,8 +0,0 @@
1
- ---
2
- extends: relaxed
3
-
4
- rules:
5
- indentation:
6
- indent-sequences: false
7
- line-length:
8
- max: 1000
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "active_record-virtual_attributes"
5
-
6
- # any helper that is not rspec specific
7
- Dir['./spec/support/**/*.rb'].sort.select { |f| !File.read(f).include?("RSpec") }.each { |f| require f }
8
-
9
- # models for local testing
10
- Database.new.setup.migrate
11
- require_relative "../seed"
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -e
5
-
6
- bundle install
7
- echo
8
-
9
- echo "Setting up the postgres database for specs..."
10
- echo "SELECT 'CREATE DATABASE virtual_attributes' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'virtual_attributes')\gexec" | psql -U postgres
11
-
12
- echo "Setting up the mysql database for specs..."
13
- mysql -u root -e 'CREATE SCHEMA IF NOT EXISTS 'virtual_attributes';'
data/renovate.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "config:recommended"
5
- ]
6
- }
data/seed.rb DELETED
@@ -1,3 +0,0 @@
1
- Author.create_with_books(3)
2
- Author.create_with_books(4)
3
- Author.create_with_books(2)