active_type 2.1.1 → 2.3.0

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: b0a5d8d33884c5002323fee2411daea972323f973b14f885ea5b3c6336569f8f
4
- data.tar.gz: 4b29935992035498d74b4c4d80c1041e17adc890234f81357828fe71e723288d
3
+ metadata.gz: b818373b67ad6b12646808562b48545c2c32ed846073660013132e619fc689c6
4
+ data.tar.gz: 204ebaf99158e1dd12f4255bf005cc123373ffaca797673427a8bb87981bbdae
5
5
  SHA512:
6
- metadata.gz: a853c942d84f065a4f1be9fad10801f635f5d759bbb969bc655d2160d0e9757f579147f0197f52af0335eb412e1cea164a78eff56ce6747f9ca36a2340fdb36f
7
- data.tar.gz: b91df99ae7b73ee3702d05b9d70bcde4a45623054293cc3ccbcedd3d6c83c22a5ac2261ca140730fd5afd3299c96ad71b275102a0ac5612260e0d5771cc11f8d
6
+ metadata.gz: 26c254234076e2ad182baf8c279d1eaec7e78b388e44682da5323fa429313e0bb3ecb001d175eb2bdc0ae081962f1576f07f73900f7cefe67d5f0f423407ab22
7
+ data.tar.gz: b114398d46139b9ed15228392b231fd8198b734e6d7f821b09752bc84442f3dd52508dbdf4f7ca1411c971ab02dfc0ed1ee470755d3108cf7b1137f22e184a51
@@ -28,8 +28,6 @@ jobs:
28
28
  gemfile: Gemfile.6.0.sqlite3
29
29
  - ruby: "2.6.3"
30
30
  gemfile: Gemfile.6.1.sqlite3
31
- - ruby: "2.6.3"
32
- gemfile: Gemfile.7.0.sqlite3
33
31
  - ruby: "2.7.4"
34
32
  gemfile: Gemfile.5.2.sqlite3
35
33
  - ruby: "2.7.4"
@@ -97,10 +95,6 @@ jobs:
97
95
  uses: ruby/setup-ruby@v1
98
96
  with:
99
97
  ruby-version: ${{ matrix.ruby }}
100
- - name: Install database client
101
- run: |
102
- sudo apt-get update
103
- sudo apt-get install -y mariadb-client libmariadbclient-dev
104
98
  - name: Bundle
105
99
  run: |
106
100
  gem install bundler:2.2.27
data/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## Unreleased changes
6
6
 
7
+ ## 2.3.0 (2022-07-21)
8
+
9
+ * Fixed: Fixed an issue when certain keywords are used as attribute names. Thanks to @tom-kuca.
10
+ * Fixed: Original Rails #attribute method now aliased as #ar_attribute correctly. Thanks to @sudoremo.
11
+ * Fixed: ActiveType::Object#serializable_hash includes virtual attributes.
12
+
13
+ ## 2.2.0 (2022-06-02)
14
+
15
+ * Fixed: ActiveType now actually works for Rails 7. Sorry for that. Thanks to @atcruice.
16
+
7
17
  ## 2.1.1 (2021-12-22)
8
18
 
9
19
  * Fixed: Ruby compiler warning and suboptimal attribut name validation. Thanks to @remofrizsche.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.1.1)
4
+ active_type (2.2.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
data/Gemfile.4.2.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.1.1)
4
+ active_type (2.2.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.1.1)
4
+ active_type (2.2.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  rspec (~> 3.4)
57
57
 
58
58
  BUNDLED WITH
59
- 2.2.16
59
+ 2.2.27
data/Gemfile.5.2.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.1.1)
4
+ active_type (2.2.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.1.1)
4
+ active_type (2.2.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  sqlite3
57
57
 
58
58
  BUNDLED WITH
59
- 2.2.16
59
+ 2.2.27
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.1.1)
4
+ active_type (2.2.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  sqlite3
57
57
 
58
58
  BUNDLED WITH
59
- 2.2.16
59
+ 2.2.27
data/Gemfile.6.1.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.1.1)
4
+ active_type (2.2.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  rspec (~> 3.4)
57
57
 
58
58
  BUNDLED WITH
59
- 2.2.16
59
+ 2.2.27
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.1.1)
4
+ active_type (2.2.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  sqlite3
57
57
 
58
58
  BUNDLED WITH
59
- 2.2.16
59
+ 2.2.27
data/Gemfile.7.0.pg CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'activerecord', '~>6.1.0'
3
+ gem 'activerecord', '~>7.0.3'
4
4
  gem 'rspec', '~>3.4'
5
5
  gem 'pg'
6
6
  gem 'rake'
data/Gemfile.7.0.pg.lock CHANGED
@@ -1,54 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.1.1)
4
+ active_type (2.2.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (6.1.4.4)
11
- activesupport (= 6.1.4.4)
12
- activerecord (6.1.4.4)
13
- activemodel (= 6.1.4.4)
14
- activesupport (= 6.1.4.4)
15
- activesupport (6.1.4.4)
10
+ activemodel (7.0.3)
11
+ activesupport (= 7.0.3)
12
+ activerecord (7.0.3)
13
+ activemodel (= 7.0.3)
14
+ activesupport (= 7.0.3)
15
+ activesupport (7.0.3)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 1.6, < 2)
18
18
  minitest (>= 5.1)
19
19
  tzinfo (~> 2.0)
20
- zeitwerk (~> 2.3)
21
- concurrent-ruby (1.1.9)
22
- diff-lcs (1.4.4)
23
- gemika (0.6.1)
24
- i18n (1.8.11)
20
+ concurrent-ruby (1.1.10)
21
+ diff-lcs (1.5.0)
22
+ gemika (0.7.1)
23
+ i18n (1.10.0)
25
24
  concurrent-ruby (~> 1.0)
26
25
  minitest (5.15.0)
27
- pg (1.2.3)
26
+ pg (1.3.5)
28
27
  rake (13.0.6)
29
- rspec (3.10.0)
30
- rspec-core (~> 3.10.0)
31
- rspec-expectations (~> 3.10.0)
32
- rspec-mocks (~> 3.10.0)
33
- rspec-core (3.10.1)
34
- rspec-support (~> 3.10.0)
35
- rspec-expectations (3.10.1)
28
+ rspec (3.11.0)
29
+ rspec-core (~> 3.11.0)
30
+ rspec-expectations (~> 3.11.0)
31
+ rspec-mocks (~> 3.11.0)
32
+ rspec-core (3.11.0)
33
+ rspec-support (~> 3.11.0)
34
+ rspec-expectations (3.11.0)
36
35
  diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.10.0)
38
- rspec-mocks (3.10.2)
36
+ rspec-support (~> 3.11.0)
37
+ rspec-mocks (3.11.1)
39
38
  diff-lcs (>= 1.2.0, < 2.0)
40
- rspec-support (~> 3.10.0)
41
- rspec-support (3.10.3)
39
+ rspec-support (~> 3.11.0)
40
+ rspec-support (3.11.0)
42
41
  tzinfo (2.0.4)
43
42
  concurrent-ruby (~> 1.0)
44
- zeitwerk (2.5.1)
45
43
 
46
44
  PLATFORMS
47
45
  ruby
48
46
 
49
47
  DEPENDENCIES
50
48
  active_type!
51
- activerecord (~> 6.1.0)
49
+ activerecord (~> 7.0.3)
52
50
  gemika
53
51
  pg
54
52
  rake
data/Gemfile.7.0.sqlite3 CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'activerecord', '~>6.1.0'
3
+ gem 'activerecord', '~>7.0.3'
4
4
  gem 'rspec', '~>3.4'
5
5
  gem 'sqlite3'
6
6
  gem 'rake'
@@ -1,54 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (2.1.1)
4
+ active_type (2.2.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (6.1.4.4)
11
- activesupport (= 6.1.4.4)
12
- activerecord (6.1.4.4)
13
- activemodel (= 6.1.4.4)
14
- activesupport (= 6.1.4.4)
15
- activesupport (6.1.4.4)
10
+ activemodel (7.0.3)
11
+ activesupport (= 7.0.3)
12
+ activerecord (7.0.3)
13
+ activemodel (= 7.0.3)
14
+ activesupport (= 7.0.3)
15
+ activesupport (7.0.3)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 1.6, < 2)
18
18
  minitest (>= 5.1)
19
19
  tzinfo (~> 2.0)
20
- zeitwerk (~> 2.3)
21
- concurrent-ruby (1.1.9)
22
- diff-lcs (1.4.4)
23
- gemika (0.6.1)
24
- i18n (1.8.11)
20
+ concurrent-ruby (1.1.10)
21
+ diff-lcs (1.5.0)
22
+ gemika (0.7.1)
23
+ i18n (1.10.0)
25
24
  concurrent-ruby (~> 1.0)
26
25
  minitest (5.15.0)
27
26
  rake (13.0.6)
28
- rspec (3.10.0)
29
- rspec-core (~> 3.10.0)
30
- rspec-expectations (~> 3.10.0)
31
- rspec-mocks (~> 3.10.0)
32
- rspec-core (3.10.1)
33
- rspec-support (~> 3.10.0)
34
- rspec-expectations (3.10.1)
27
+ rspec (3.11.0)
28
+ rspec-core (~> 3.11.0)
29
+ rspec-expectations (~> 3.11.0)
30
+ rspec-mocks (~> 3.11.0)
31
+ rspec-core (3.11.0)
32
+ rspec-support (~> 3.11.0)
33
+ rspec-expectations (3.11.0)
35
34
  diff-lcs (>= 1.2.0, < 2.0)
36
- rspec-support (~> 3.10.0)
37
- rspec-mocks (3.10.2)
35
+ rspec-support (~> 3.11.0)
36
+ rspec-mocks (3.11.1)
38
37
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.10.0)
40
- rspec-support (3.10.3)
38
+ rspec-support (~> 3.11.0)
39
+ rspec-support (3.11.0)
41
40
  sqlite3 (1.4.2)
42
41
  tzinfo (2.0.4)
43
42
  concurrent-ruby (~> 1.0)
44
- zeitwerk (2.5.1)
45
43
 
46
44
  PLATFORMS
47
45
  ruby
48
46
 
49
47
  DEPENDENCIES
50
48
  active_type!
51
- activerecord (~> 6.1.0)
49
+ activerecord (~> 7.0.3)
52
50
  gemika
53
51
  rake
54
52
  rspec (~> 3.4)
@@ -16,11 +16,15 @@ module ActiveType
16
16
  @allow_destroy = options.fetch(:allow_destroy, false)
17
17
  @reject_if = options.delete(:reject_if)
18
18
  @options = options.dup
19
- @index_errors = if ActiveRecord::VERSION::MAJOR < 5
20
- @options[:index_errors]
21
- else
22
- @options[:index_errors] || ActiveRecord::Base.index_nested_attribute_errors
23
- end
19
+
20
+ @index_errors = case
21
+ when ActiveRecord::VERSION::MAJOR < 5
22
+ @options[:index_errors]
23
+ when ActiveRecord::VERSION::MAJOR < 7
24
+ @options[:index_errors] || ActiveRecord::Base.index_nested_attribute_errors
25
+ else
26
+ @options[:index_errors] || ActiveRecord.index_nested_attribute_errors
27
+ end
24
28
  end
25
29
 
26
30
  def assign_attributes(parent, attributes)
@@ -126,7 +130,7 @@ module ActiveType
126
130
  end
127
131
 
128
132
  def add_errors_to_parent(parent, child, index)
129
- if ActiveRecord::VERSION::MAJOR >= 6 && ActiveRecord::VERSION::MINOR >= 1
133
+ if Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new("6.1")
130
134
  child.errors.each do |error|
131
135
  attribute = translate_error_attribute(error.attribute, index)
132
136
  parent.errors.add(attribute, error.message)
@@ -101,7 +101,7 @@ module ActiveType
101
101
  def columns_hash(table_name)
102
102
  {}
103
103
  end
104
-
104
+
105
105
  def columns_hash?(table_name)
106
106
  return false
107
107
  end
@@ -144,6 +144,10 @@ module ActiveType
144
144
  []
145
145
  end
146
146
 
147
+ def _query_by_sql(*)
148
+ []
149
+ end
150
+
147
151
  end
148
152
 
149
153
  def destroy
@@ -1,3 +1,3 @@
1
1
  module ActiveType
2
- VERSION = '2.1.1'
2
+ VERSION = '2.3.0'
3
3
  end
@@ -100,7 +100,7 @@ module ActiveType
100
100
 
101
101
  @module.module_eval <<-BODY, __FILE__, __LINE__ + 1
102
102
  def #{name}_changed?
103
- #{name} != virtual_attributes_were["#{name}"]
103
+ self.#{name} != virtual_attributes_were["#{name}"]
104
104
  end
105
105
  BODY
106
106
 
@@ -137,6 +137,7 @@ module ActiveType
137
137
  class << self
138
138
  if method_defined?(:attribute)
139
139
  alias_method :ar_attribute, :attribute
140
+ alias_method :attribute, :at_attribute
140
141
  end
141
142
  end
142
143
  end
@@ -217,6 +218,10 @@ module ActiveType
217
218
  end
218
219
  end
219
220
 
221
+ def attribute_names
222
+ super + self.class._virtual_column_names
223
+ end
224
+
220
225
  def changed?
221
226
  self.class._virtual_column_names.any? { |attr| virtual_attributes_were[attr] != send(attr) } || super
222
227
  end
@@ -273,7 +278,7 @@ module ActiveType
273
278
  if value.is_a?(String) && value.length > 50
274
279
  "#{value[0, 50]}...".inspect
275
280
  elsif value.is_a?(Date) || value.is_a?(Time)
276
- %("#{value.to_s(:db)}")
281
+ %("#{value.to_formatted_s(:db)}")
277
282
  elsif value.is_a?(Array) && value.size > 10
278
283
  inspected = value.first(10).inspect
279
284
  %(#{inspected[0...-1]}, ...])
@@ -323,7 +328,7 @@ module ActiveType
323
328
  end
324
329
  end
325
330
 
326
- def attribute(name, *args)
331
+ def at_attribute(name, *args)
327
332
  options = args.extract_options!
328
333
  type = args.first
329
334
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_type
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Kraze
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-02-15 00:00:00.000000000 Z
12
+ date: 2022-08-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler