activerecord-virtual_attributes 7.0.0 → 7.1.1

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: 26048751ad2fe218660a4b62fa6c89d6467e7d33404c463154a041cf638ff43c
4
+ data.tar.gz: 8c2302076104393e4e4eac994e854a951ee6c0588b3fbfefc6c95f3d8d905861
5
5
  SHA512:
6
- metadata.gz: 10295799b997217903b155c7ed84e9ee82bad2cf6c208b6aa140dc94e66df9b4ed8fbcf13418a2feadf075e7f93b2c550d7a94b698aae0c08b6d29a4d5ebe159
7
- data.tar.gz: 1663fd7ab8af93e3419b6a1ae608c94d55df957b45d904e38b31a3b5f93667159e6ee10e667f560174b12cc2b66e936e20bcadc4ac98a45953ed3923f21cac94
6
+ metadata.gz: 34b460bb1293c44743f26c0b91d62d857f53158022f2777ffb29f97a2279b6a9bbd3d19e4cd83dafaee035061093da669da4ac2bb749f1524258ae5db8d5577c
7
+ data.tar.gz: 2b7876b8d6f5c0eeafaf2f2f7740943ead1cc25b0c211ee84e44365609d86c659c328103c432d0c01184d1c09f13f2af5226c9d05614ac7c875392e503ae981a
data/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@ The versioning of this gem follows ActiveRecord versioning, and does not follow
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [7.1.1] - 2025-06-18
8
+
9
+ * Deprecate virtual_delegate without a type [#188](https://github.com/ManageIQ/activerecord-virtual_attributes/pull/188)
10
+
11
+ ## [7.1.0] - 2025-02-19
12
+
13
+ * Use TableAlias for table aliasing [#168](https://github.com/ManageIQ/activerecord-virtual_attributes/pull/168)
14
+ * Rails 7.1 support
15
+
7
16
  ## [7.0.0] - 2024-08-01
8
17
 
9
18
  * Use Arel.literal [#154](https://github.com/ManageIQ/activerecord-virtual_attributes/pull/154)
@@ -106,7 +115,9 @@ The versioning of this gem follows ActiveRecord versioning, and does not follow
106
115
  * Initial Release
107
116
  * Extracted from ManageIQ/manageiq
108
117
 
109
- [Unreleased]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v7.0.0...HEAD
118
+ [Unreleased]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v7.1.1...HEAD
119
+ [7.1.1]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v7.1.0...v7.1.1
120
+ [7.1.0]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v7.0.0...v7.1.0
110
121
  [7.0.0]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v6.1.2...v7.0.0
111
122
  [6.1.2]: https://github.com/ManageIQ/activerecord-virtual_attributes/compare/v6.1.1...v6.1.2
112
123
  [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,18 @@ 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_runtime_dependency "activerecord", "~> 7.1", ">=7.1.5.1"
32
32
 
33
33
  spec.add_development_dependency "byebug"
34
34
  spec.add_development_dependency "database_cleaner-active_record", "~> 2.1"
35
35
  spec.add_development_dependency "db-query-matchers"
36
- spec.add_development_dependency "manageiq-style"
36
+ spec.add_development_dependency "manageiq-style", ">= 1.5.4"
37
+
37
38
  spec.add_development_dependency "mysql2"
38
39
  spec.add_development_dependency "pg"
39
40
  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.1".freeze
4
4
  end
5
5
  end
@@ -118,45 +118,3 @@ module ActiveRecord
118
118
  end
119
119
  end
120
120
 
121
- # fixed in https://github.com/rails/rails/pull/45642
122
- if ActiveRecord.version < Gem::Version.new(7.1)
123
- module Arel # :nodoc: all
124
- # rubocop:disable Naming/MethodName
125
- # rubocop:disable Naming/MethodParameterName
126
- # rubocop:disable Style/ConditionalAssignment
127
- module Visitors
128
- # rails 6.1...
129
- class ToSql
130
- private
131
-
132
- def visit_Arel_Nodes_HomogeneousIn(o, collector)
133
- collector.preparable = false
134
-
135
- # change:
136
- # See https://github.com/rails/rails/pull/45642
137
- visit(o.left, collector)
138
- # /change
139
-
140
- if o.type == :in
141
- collector << " IN ("
142
- else
143
- collector << " NOT IN ("
144
- end
145
-
146
- values = o.casted_values
147
-
148
- if values.empty?
149
- collector << @connection.quote(nil)
150
- else
151
- collector.add_binds(values, o.proc_for_binds, &bind_block)
152
- end
153
-
154
- collector << ")"
155
- end
156
- end
157
- end
158
- # rubocop:enable Naming/MethodName
159
- # rubocop:enable Naming/MethodParameterName
160
- # rubocop:enable Style/ConditionalAssignment
161
- end
162
- end
@@ -10,8 +10,7 @@ module ActiveRecord
10
10
  extend ActiveSupport::Concern
11
11
 
12
12
  included do
13
- class_attribute :virtual_delegates_to_define, :instance_accessor => false
14
- self.virtual_delegates_to_define = {}
13
+ class_attribute :virtual_delegates_to_define, :instance_accessor => false, :default => {}
15
14
  end
16
15
 
17
16
  module ClassMethods
@@ -25,6 +24,10 @@ module ActiveRecord
25
24
  raise ArgumentError, 'Delegation needs an association. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, to: :greeter).'
26
25
  end
27
26
 
27
+ unless options[:type]
28
+ ActiveRecord::VirtualAttributes.deprecator.warn("Calling virtual_delegate without :type is now deprecated", caller)
29
+ end
30
+
28
31
  to = to.to_s
29
32
  if to.include?(".") && methods.size > 1
30
33
  raise ArgumentError, 'Delegation only supports specifying a method name when defining a single virtual method'
@@ -271,11 +274,9 @@ module ActiveRecord
271
274
  def self.select_from_alias_table(to_klass, src_relation)
272
275
  to_table = to_klass.arel_table
273
276
  # 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
277
+ if to_table.name == src_relation.name
277
278
  # use a table alias to not conflict with table name in the primary query
278
- to_table.table_alias = "#{to_table.table_name}_sub"
279
+ to_table = to_table.alias("#{to_table.name}_sub")
279
280
  end
280
281
  to_table
281
282
  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
@@ -170,6 +170,8 @@ module ActiveRecord
170
170
  class Branch
171
171
  prepend(Module.new {
172
172
  # from branched.rb 7.0
173
+ # not going to modify rails code for rubocops
174
+ # rubocop:disable Lint/AmbiguousOperatorPrecedence
173
175
  def grouped_records
174
176
  h = {}
175
177
  polymorphic_parent = !root? && parent.polymorphic?
@@ -184,6 +186,7 @@ module ActiveRecord
184
186
  end
185
187
  h
186
188
  end
189
+ # rubocop:enable Lint/AmbiguousOperatorPrecedence
187
190
 
188
191
  # branched.rb 7.0
189
192
  def preloaders_for_reflection(reflection, reflection_records)
@@ -1,6 +1,7 @@
1
1
  require "active_support/concern"
2
2
  require "active_record"
3
3
 
4
+ require "active_record/virtual_attributes/version"
4
5
  require "active_record/virtual_attributes/virtual_includes"
5
6
  require "active_record/virtual_attributes/virtual_arel"
6
7
  require "active_record/virtual_attributes/virtual_delegates"
@@ -37,9 +38,12 @@ module ActiveRecord
37
38
  ActiveRecord::Type.register(:string_set, Type::StringSet)
38
39
  ActiveRecord::Type.register(:symbol, Type::Symbol)
39
40
 
41
+ def self.deprecator
42
+ @deprecator ||= ActiveSupport::Deprecation.new(ActiveRecord::VirtualAttributes::VERSION, "virtual_attributes")
43
+ end
44
+
40
45
  included do
41
- class_attribute :virtual_attributes_to_define, :instance_accessor => false
42
- self.virtual_attributes_to_define = {}
46
+ class_attribute :virtual_attributes_to_define, :instance_accessor => false, :default => {}
43
47
  end
44
48
 
45
49
  module ClassMethods
metadata CHANGED
@@ -1,14 +1,14 @@
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.1
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-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '7.0'
19
+ version: '7.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 7.1.5.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '7.0'
29
+ version: '7.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 7.1.5.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: byebug
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +78,14 @@ dependencies:
72
78
  requirements:
73
79
  - - ">="
74
80
  - !ruby/object:Gem::Version
75
- version: '0'
81
+ version: 1.5.4
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
86
  - - ">="
81
87
  - !ruby/object:Gem::Version
82
- version: '0'
88
+ version: 1.5.4
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: mysql2
85
91
  requirement: !ruby/object:Gem::Requirement
@@ -171,23 +177,12 @@ executables: []
171
177
  extensions: []
172
178
  extra_rdoc_files: []
173
179
  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
180
  - CHANGELOG.md
184
181
  - Gemfile
185
182
  - LICENSE.txt
186
183
  - README.md
187
184
  - Rakefile
188
185
  - activerecord-virtual_attributes.gemspec
189
- - bin/console
190
- - bin/setup
191
186
  - init.rb
192
187
  - lib/active_record-virtual_attributes.rb
193
188
  - lib/active_record/virtual_attributes.rb
@@ -201,8 +196,6 @@ files:
201
196
  - lib/active_record/virtual_attributes/virtual_reflections.rb
202
197
  - lib/active_record/virtual_attributes/virtual_total.rb
203
198
  - lib/activerecord-virtual_attributes.rb
204
- - renovate.json
205
- - seed.rb
206
199
  homepage: https://github.com/ManageIQ/activerecord-virtual_attributes
207
200
  licenses:
208
201
  - Apache 2.0
@@ -226,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
219
  - !ruby/object:Gem::Version
227
220
  version: '0'
228
221
  requirements: []
229
- rubygems_version: 3.5.9
222
+ rubygems_version: 3.5.22
230
223
  signing_key:
231
224
  specification_version: 4
232
225
  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)