activerecord 7.0.7.2 → 7.0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +64 -0
- data/lib/active_record/associations/collection_association.rb +1 -1
- data/lib/active_record/associations/collection_proxy.rb +5 -0
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +1 -1
- data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +6 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +1 -4
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/migration/compatibility.rb +12 -54
- data/lib/active_record/migration.rb +52 -3
- data/lib/active_record/table_metadata.rb +1 -1
- data/lib/arel/nodes/and.rb +4 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86d8c480f7ffe8f97672c80fc0dd5e9d22592050951f5332b9ec4ba6184c5ce3
|
4
|
+
data.tar.gz: 9bb6069ffe3fa18c68c05d9e660888567bea66a1de38eab45221fd406b0ca6f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56d025283811169a2f9c663f3ab682d0c22e42fdd3338e5796380d49bec87b625729a3f00bd64b4fcf484cd49272ad9b0ec57873ff46db9c800dc4d97e67ba68
|
7
|
+
data.tar.gz: fda3fd3d5596fe18e6bdaa55c1e8fd378c41b14c5b6ce0bf2aea5b507a9ed928330dc75eba5f66bb8b2e6123312ca1b1eb621fdf8e62c88a2b8734e2af383e3a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,67 @@
|
|
1
|
+
## Rails 7.0.8.1 (February 21, 2024) ##
|
2
|
+
|
3
|
+
* No changes.
|
4
|
+
|
5
|
+
|
6
|
+
## Rails 7.0.8 (September 09, 2023) ##
|
7
|
+
|
8
|
+
* Fix `change_column` not setting `precision: 6` on `datetime` columns when
|
9
|
+
using 7.0+ Migrations and SQLite.
|
10
|
+
|
11
|
+
*Hartley McGuire*
|
12
|
+
|
13
|
+
* Fix unscope is not working in specific case
|
14
|
+
|
15
|
+
Before:
|
16
|
+
```ruby
|
17
|
+
Post.where(id: 1...3).unscope(where: :id).to_sql # "SELECT `posts`.* FROM `posts` WHERE `posts`.`id` >= 1 AND `posts`.`id` < 3"
|
18
|
+
|
19
|
+
```
|
20
|
+
|
21
|
+
After:
|
22
|
+
```ruby
|
23
|
+
Post.where(id: 1...3).unscope(where: :id).to_sql # "SELECT `posts`.* FROM `posts`"
|
24
|
+
```
|
25
|
+
|
26
|
+
Fixes #48094.
|
27
|
+
|
28
|
+
*Kazuya Hatanaka*
|
29
|
+
|
30
|
+
* Fix associations to a STI model including a `class_name` parameter
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
class Product < ApplicationRecord
|
34
|
+
has_many :requests, as: :requestable, class_name: "ProductRequest", dependent: :destroy
|
35
|
+
end
|
36
|
+
|
37
|
+
# STI tables
|
38
|
+
class Request < ApplicationRecord
|
39
|
+
belongs_to :requestable, polymorphic: true
|
40
|
+
|
41
|
+
validate :request_type, presence: true
|
42
|
+
end
|
43
|
+
|
44
|
+
class ProductRequest < Request
|
45
|
+
belongs_to :user
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
Accessing such association would lead to:
|
50
|
+
|
51
|
+
```
|
52
|
+
table_metadata.rb:22:in `has_column?': undefined method `key?' for nil:NilClass (NoMethodError)
|
53
|
+
```
|
54
|
+
|
55
|
+
*Romain Filinto*
|
56
|
+
|
57
|
+
* Fix `change_table` setting datetime precision for 6.1 Migrations
|
58
|
+
|
59
|
+
*Hartley McGuire*
|
60
|
+
|
61
|
+
* Fix change_column setting datetime precision for 6.1 Migrations
|
62
|
+
|
63
|
+
*Hartley McGuire*
|
64
|
+
|
1
65
|
## Rails 7.0.7.2 (August 22, 2023) ##
|
2
66
|
|
3
67
|
* No changes.
|
@@ -4,6 +4,12 @@ module ActiveRecord
|
|
4
4
|
module ConnectionAdapters
|
5
5
|
module SQLite3
|
6
6
|
class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
|
7
|
+
def change_column(column_name, type, **options)
|
8
|
+
name = column_name.to_s
|
9
|
+
@columns_hash[name] = nil
|
10
|
+
column(name, type, **options)
|
11
|
+
end
|
12
|
+
|
7
13
|
def references(*args, **options)
|
8
14
|
super(*args, type: :integer, **options)
|
9
15
|
end
|
@@ -287,10 +287,7 @@ module ActiveRecord
|
|
287
287
|
|
288
288
|
def change_column(table_name, column_name, type, **options) # :nodoc:
|
289
289
|
alter_table(table_name) do |definition|
|
290
|
-
definition
|
291
|
-
self.type = aliased_types(type.to_s, type)
|
292
|
-
self.options.merge!(options)
|
293
|
-
end
|
290
|
+
definition.change_column(column_name, type, **options)
|
294
291
|
end
|
295
292
|
end
|
296
293
|
|
@@ -56,12 +56,13 @@ module ActiveRecord
|
|
56
56
|
super
|
57
57
|
end
|
58
58
|
|
59
|
-
def
|
60
|
-
if
|
61
|
-
|
62
|
-
else
|
63
|
-
super
|
59
|
+
def change_column(table_name, column_name, type, **options)
|
60
|
+
if type == :datetime
|
61
|
+
options[:precision] ||= nil
|
64
62
|
end
|
63
|
+
|
64
|
+
type = PostgreSQLCompat.compatible_timestamp_type(type, connection)
|
65
|
+
super
|
65
66
|
end
|
66
67
|
|
67
68
|
module TableDefinition
|
@@ -70,6 +71,11 @@ module ActiveRecord
|
|
70
71
|
super
|
71
72
|
end
|
72
73
|
|
74
|
+
def change(name, type, index: nil, **options)
|
75
|
+
options[:precision] ||= nil
|
76
|
+
super
|
77
|
+
end
|
78
|
+
|
73
79
|
def column(name, type, index: nil, **options)
|
74
80
|
options[:precision] ||= nil
|
75
81
|
super
|
@@ -81,7 +87,7 @@ module ActiveRecord
|
|
81
87
|
class << t
|
82
88
|
prepend TableDefinition
|
83
89
|
end
|
84
|
-
|
90
|
+
super
|
85
91
|
end
|
86
92
|
end
|
87
93
|
|
@@ -105,30 +111,6 @@ module ActiveRecord
|
|
105
111
|
end
|
106
112
|
end
|
107
113
|
|
108
|
-
def create_table(table_name, **options)
|
109
|
-
if block_given?
|
110
|
-
super { |t| yield compatible_table_definition(t) }
|
111
|
-
else
|
112
|
-
super
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def change_table(table_name, **options)
|
117
|
-
if block_given?
|
118
|
-
super { |t| yield compatible_table_definition(t) }
|
119
|
-
else
|
120
|
-
super
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def create_join_table(table_1, table_2, **options)
|
125
|
-
if block_given?
|
126
|
-
super { |t| yield compatible_table_definition(t) }
|
127
|
-
else
|
128
|
-
super
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
114
|
def add_reference(table_name, ref_name, **options)
|
133
115
|
if connection.adapter_name == "SQLite"
|
134
116
|
options[:type] = :integer
|
@@ -182,30 +164,6 @@ module ActiveRecord
|
|
182
164
|
end
|
183
165
|
end
|
184
166
|
|
185
|
-
def create_table(table_name, **options)
|
186
|
-
if block_given?
|
187
|
-
super { |t| yield compatible_table_definition(t) }
|
188
|
-
else
|
189
|
-
super
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
def change_table(table_name, **options)
|
194
|
-
if block_given?
|
195
|
-
super { |t| yield compatible_table_definition(t) }
|
196
|
-
else
|
197
|
-
super
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
def create_join_table(table_1, table_2, **options)
|
202
|
-
if block_given?
|
203
|
-
super { |t| yield compatible_table_definition(t) }
|
204
|
-
else
|
205
|
-
super
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
167
|
def add_timestamps(table_name, **options)
|
210
168
|
options[:precision] ||= nil
|
211
169
|
super
|
@@ -551,6 +551,41 @@ module ActiveRecord
|
|
551
551
|
|
552
552
|
# This must be defined before the inherited hook, below
|
553
553
|
class Current < Migration # :nodoc:
|
554
|
+
def create_table(table_name, **options)
|
555
|
+
if block_given?
|
556
|
+
super { |t| yield compatible_table_definition(t) }
|
557
|
+
else
|
558
|
+
super
|
559
|
+
end
|
560
|
+
end
|
561
|
+
|
562
|
+
def change_table(table_name, **options)
|
563
|
+
if block_given?
|
564
|
+
super { |t| yield compatible_table_definition(t) }
|
565
|
+
else
|
566
|
+
super
|
567
|
+
end
|
568
|
+
end
|
569
|
+
|
570
|
+
def create_join_table(table_1, table_2, **options)
|
571
|
+
if block_given?
|
572
|
+
super { |t| yield compatible_table_definition(t) }
|
573
|
+
else
|
574
|
+
super
|
575
|
+
end
|
576
|
+
end
|
577
|
+
|
578
|
+
def drop_table(table_name, **options)
|
579
|
+
if block_given?
|
580
|
+
super { |t| yield compatible_table_definition(t) }
|
581
|
+
else
|
582
|
+
super
|
583
|
+
end
|
584
|
+
end
|
585
|
+
|
586
|
+
def compatible_table_definition(t)
|
587
|
+
t
|
588
|
+
end
|
554
589
|
end
|
555
590
|
|
556
591
|
def self.inherited(subclass) # :nodoc:
|
@@ -916,9 +951,7 @@ module ActiveRecord
|
|
916
951
|
end
|
917
952
|
|
918
953
|
def method_missing(method, *arguments, &block)
|
919
|
-
|
920
|
-
|
921
|
-
say_with_time "#{method}(#{arg_list})" do
|
954
|
+
say_with_time "#{method}(#{format_arguments(arguments)})" do
|
922
955
|
unless connection.respond_to? :revert
|
923
956
|
unless arguments.empty? || [:execute, :enable_extension, :disable_extension].include?(method)
|
924
957
|
arguments[0] = proper_table_name(arguments.first, table_name_options)
|
@@ -1026,6 +1059,22 @@ module ActiveRecord
|
|
1026
1059
|
end
|
1027
1060
|
end
|
1028
1061
|
|
1062
|
+
def format_arguments(arguments)
|
1063
|
+
arg_list = arguments[0...-1].map(&:inspect)
|
1064
|
+
last_arg = arguments.last
|
1065
|
+
if last_arg.is_a?(Hash)
|
1066
|
+
last_arg = last_arg.reject { |k, _v| internal_option?(k) }
|
1067
|
+
arg_list << last_arg.inspect unless last_arg.empty?
|
1068
|
+
else
|
1069
|
+
arg_list << last_arg.inspect
|
1070
|
+
end
|
1071
|
+
arg_list.join(", ")
|
1072
|
+
end
|
1073
|
+
|
1074
|
+
def internal_option?(option_name)
|
1075
|
+
option_name.start_with?("_")
|
1076
|
+
end
|
1077
|
+
|
1029
1078
|
def command_recorder
|
1030
1079
|
CommandRecorder.new(connection)
|
1031
1080
|
end
|
data/lib/arel/nodes/and.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.0.
|
4
|
+
version: 7.0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 7.0.
|
19
|
+
version: 7.0.8.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 7.0.
|
26
|
+
version: 7.0.8.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 7.0.
|
33
|
+
version: 7.0.8.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 7.0.
|
40
|
+
version: 7.0.8.1
|
41
41
|
description: Databases on Rails. Build a persistent domain model by mapping database
|
42
42
|
tables to Ruby classes. Strong conventions for associations, validations, aggregations,
|
43
43
|
migrations, and testing come baked-in.
|
@@ -434,10 +434,10 @@ licenses:
|
|
434
434
|
- MIT
|
435
435
|
metadata:
|
436
436
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
437
|
-
changelog_uri: https://github.com/rails/rails/blob/v7.0.
|
438
|
-
documentation_uri: https://api.rubyonrails.org/v7.0.
|
437
|
+
changelog_uri: https://github.com/rails/rails/blob/v7.0.8.1/activerecord/CHANGELOG.md
|
438
|
+
documentation_uri: https://api.rubyonrails.org/v7.0.8.1/
|
439
439
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
440
|
-
source_code_uri: https://github.com/rails/rails/tree/v7.0.
|
440
|
+
source_code_uri: https://github.com/rails/rails/tree/v7.0.8.1/activerecord
|
441
441
|
rubygems_mfa_required: 'true'
|
442
442
|
post_install_message:
|
443
443
|
rdoc_options:
|
@@ -456,7 +456,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
456
456
|
- !ruby/object:Gem::Version
|
457
457
|
version: '0'
|
458
458
|
requirements: []
|
459
|
-
rubygems_version: 3.
|
459
|
+
rubygems_version: 3.2.22
|
460
460
|
signing_key:
|
461
461
|
specification_version: 4
|
462
462
|
summary: Object-relational mapper framework (part of Rails).
|