activerecord 7.0.0.rc3 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activerecord might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 458dd96fbc8713da75b5ee24f47f90b3330c3baf9f5ce2db5bda1eb2c5ca3c01
4
- data.tar.gz: fc473846b0d1ee465223c5980616937a119ef0ce349154ca4c0eb3633db0790a
3
+ metadata.gz: ebfa716fe92ae11e586b89a89661980f107b3501dcbc64be179a191645046e2a
4
+ data.tar.gz: 0eb8e39ca0252342714ad4791d5a17127697a7047b4ed2c7d48a867774f8470b
5
5
  SHA512:
6
- metadata.gz: 1f7d111235cf366f0de47a9f895d8a01351344b52d5a92dda94e627e424d7b9ed72daec2b371f58fa5d7d2e99de8bb8add753aa16baca7977a1a3174443b5171
7
- data.tar.gz: 573befa4bc581ae039212f43f7c622f64a19900de064579f6314b2351457e64b74cfc5d63b37c06058da394244d585d8271f6b1f22b8646e4138e145d8b4b4d1
6
+ metadata.gz: 74365d846a7f543a82e61c3784aad30dd1de0e2a43e09ed4459a4b7b0fe9a14839a53122e12536c63d3bdcb638391390b83e6ffa4eb6a09f8713e1986674cda9
7
+ data.tar.gz: a1379b0d243f97f6827df6ff2af3a7936164ad57ad60ded0aac71aeb45def6d7cee19571de89f8d93eeeaabfc6d193b9695879b8dac5c9f7d473e85617d15bea
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## Rails 7.0.0 (December 15, 2021) ##
2
+
3
+ * Better handle SQL queries with invalid encoding.
4
+
5
+ ```ruby
6
+ Post.create(name: "broken \xC8 UTF-8")
7
+ ```
8
+
9
+ Would cause all adapters to fail in a non controlled way in the code
10
+ responsible to detect write queries.
11
+
12
+ The query is now properly passed to the database connection, which might or might
13
+ not be able to handle it, but will either succeed or failed in a more correct way.
14
+
15
+ *Jean Boussier*
16
+
17
+ * Move database and shard selection config options to a generator.
18
+
19
+ Rather than generating the config options in `production.rb` when applications are created, applications can now run a generator to create an initializer and uncomment / update options as needed. All multi-db configuration can be implemented in this initializer.
20
+
21
+ *Eileen M. Uchitelle*
22
+
1
23
  ## Rails 7.0.0.rc3 (December 14, 2021) ##
2
24
 
3
25
  * No changes.
@@ -5,6 +27,10 @@
5
27
 
6
28
  ## Rails 7.0.0.rc2 (December 14, 2021) ##
7
29
 
30
+ * No changes.
31
+
32
+ ## Rails 7.0.0.rc1 (December 06, 2021) ##
33
+
8
34
  * Remove deprecated `ActiveRecord::DatabaseConfigurations::DatabaseConfig#spec_name`.
9
35
 
10
36
  *Rafael Mendonça França*
@@ -312,7 +338,6 @@
312
338
 
313
339
  Applications may now set their the filename or path of the schema / structure dump file in their database configuration.
314
340
 
315
-
316
341
  ```yaml
317
342
  production:
318
343
  primary:
@@ -399,6 +424,8 @@
399
424
  `#with_lock` now accepts transaction options like `requires_new:`,
400
425
  `isolation:`, and `joinable:`
401
426
 
427
+ *John Mileham*
428
+
402
429
  * Adds support for deferrable foreign key constraints in PostgreSQL.
403
430
 
404
431
  By default, foreign key constraints in PostgreSQL are checked after each statement. This works for most use cases,
@@ -475,7 +502,7 @@
475
502
 
476
503
  *Alex Ghiculescu*
477
504
 
478
- * Avoid COMMENT statements in PostgreSQL structure dumps
505
+ * Avoid COMMENT statements in PostgreSQL structure dumps
479
506
 
480
507
  COMMENT statements are now omitted from the output of `db:structure:dump` when using PostgreSQL >= 11.
481
508
  This allows loading the dump without a pgsql superuser account.
@@ -528,7 +555,7 @@
528
555
 
529
556
  *Sam Bostock*
530
557
 
531
- * Add ssl support for postgresql database tasks
558
+ * Add ssl support for postgresql database tasks
532
559
 
533
560
  Add `PGSSLMODE`, `PGSSLCERT`, `PGSSLKEY` and `PGSSLROOTCERT` to pg_env from database config
534
561
  when running postgresql database tasks.
@@ -3,8 +3,12 @@
3
3
  module ActiveRecord
4
4
  module Associations
5
5
  class JoinDependency # :nodoc:
6
- autoload :JoinBase, "active_record/associations/join_dependency/join_base"
7
- autoload :JoinAssociation, "active_record/associations/join_dependency/join_association"
6
+ extend ActiveSupport::Autoload
7
+
8
+ eager_autoload do
9
+ autoload :JoinBase
10
+ autoload :JoinAssociation
11
+ end
8
12
 
9
13
  class Aliases # :nodoc:
10
14
  def initialize(tables)
@@ -26,6 +26,8 @@ module ActiveRecord
26
26
 
27
27
  def write_query?(sql) # :nodoc:
28
28
  !READ_QUERY.match?(sql)
29
+ rescue ArgumentError # Invalid encoding
30
+ !READ_QUERY.match?(sql.b)
29
31
  end
30
32
 
31
33
  def explain(arel, binds = [])
@@ -28,6 +28,8 @@ module ActiveRecord
28
28
 
29
29
  def write_query?(sql) # :nodoc:
30
30
  !READ_QUERY.match?(sql)
31
+ rescue ArgumentError # Invalid encoding
32
+ !READ_QUERY.match?(sql.b)
31
33
  end
32
34
 
33
35
  # Executes an SQL statement, returning a PG::Result object on success
@@ -569,7 +569,7 @@ module ActiveRecord
569
569
  else raise ArgumentError, "No integer type has byte size #{limit}. Use a numeric with scale 0 instead."
570
570
  end
571
571
  when "enum"
572
- raise ArgumentError "enum_type is required for enums" if enum_type.nil?
572
+ raise ArgumentError, "enum_type is required for enums" if enum_type.nil?
573
573
 
574
574
  enum_type
575
575
  else
@@ -11,6 +11,8 @@ module ActiveRecord
11
11
 
12
12
  def write_query?(sql) # :nodoc:
13
13
  !READ_QUERY.match?(sql)
14
+ rescue ArgumentError # Invalid encoding
15
+ !READ_QUERY.match?(sql.b)
14
16
  end
15
17
 
16
18
  def explain(arel, binds = [])
@@ -37,7 +37,7 @@ module ActiveRecord
37
37
  # in preserving it.
38
38
  # * <tt>:ignore_case</tt> - When true, it behaves like +:downcase+ but, it also preserves the original case in a specially
39
39
  # designated column +original_<name>+. When reading the encrypted content, the version with the original case is
40
- # server. But you can still execute queries that will ignore the case. This option can only be used when +:deterministic+
40
+ # served. But you can still execute queries that will ignore the case. This option can only be used when +:deterministic+
41
41
  # is true.
42
42
  # * <tt>:context_properties</tt> - Additional properties that will override +Context+ settings when this attribute is
43
43
  # encrypted and decrypted. E.g: +encryptor:+, +cipher:+, +message_serializer:+, etc.
@@ -10,7 +10,7 @@ module ActiveRecord
10
10
  MAJOR = 7
11
11
  MINOR = 0
12
12
  TINY = 0
13
- PRE = "rc3"
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -1001,7 +1001,7 @@ module ActiveRecord
1001
1001
  # Determines the version number of the next migration.
1002
1002
  def next_migration_number(number)
1003
1003
  if ActiveRecord.timestamped_migrations
1004
- [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % number].max
1004
+ [Time.now.utc.strftime("%Y%m%d%H%M%S").to_i, ("%.14d" % number).to_i].max
1005
1005
  else
1006
1006
  SchemaMigration.normalize_migration_number(number)
1007
1007
  end
@@ -1080,7 +1080,7 @@ module ActiveRecord
1080
1080
  # 0 then an empty array will be returned and no migrations
1081
1081
  # will be run.
1082
1082
  #
1083
- # If the +current_version+ in the schema is less than
1083
+ # If the +current_version+ in the schema is greater than
1084
1084
  # the +target_version+, then +down+ will be run.
1085
1085
  #
1086
1086
  # If none of the conditions are met, +up+ will be run with
@@ -33,7 +33,6 @@ module ActiveRecord
33
33
  @delegate_to_klass = false
34
34
  @future_result = nil
35
35
  @records = nil
36
- @limited_count = nil
37
36
  end
38
37
 
39
38
  def initialize_copy(other)
@@ -699,7 +698,6 @@ module ActiveRecord
699
698
  @offsets = @take = nil
700
699
  @cache_keys = nil
701
700
  @records = nil
702
- @limited_count = nil
703
701
  self
704
702
  end
705
703
 
@@ -974,7 +972,7 @@ module ActiveRecord
974
972
  end
975
973
 
976
974
  def limited_count
977
- @limited_count ||= limit_value ? count : limit(2).count
975
+ limit_value ? count : limit(2).count
978
976
  end
979
977
  end
980
978
  end
@@ -41,6 +41,10 @@ module ActiveRecord
41
41
  def all_versions
42
42
  order(:version).pluck(:version)
43
43
  end
44
+
45
+ def table_exists?
46
+ connection.data_source_exists?(table_name)
47
+ end
44
48
  end
45
49
 
46
50
  def version
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/active_record"
4
+
5
+ module ActiveRecord
6
+ module Generators # :nodoc:
7
+ class MultiDbGenerator < ::Rails::Generators::Base # :nodoc:
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ def create_multi_db
11
+ filename = "multi_db.rb"
12
+ template filename, "config/initializers/#{filename}"
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,44 @@
1
+ # Multi-db Configuration
2
+ #
3
+ # This file is used for configuration settings related to multiple databases.
4
+ #
5
+ # Enable Database Selector
6
+ #
7
+ # Inserts middleware to perform automatic connection switching.
8
+ # The `database_selector` hash is used to pass options to the DatabaseSelector
9
+ # middleware. The `delay` is used to determine how long to wait after a write
10
+ # to send a subsequent read to the primary.
11
+ #
12
+ # The `database_resolver` class is used by the middleware to determine which
13
+ # database is appropriate to use based on the time delay.
14
+ #
15
+ # The `database_resolver_context` class is used by the middleware to set
16
+ # timestamps for the last write to the primary. The resolver uses the context
17
+ # class timestamps to determine how long to wait before reading from the
18
+ # replica.
19
+ #
20
+ # By default Rails will store a last write timestamp in the session. The
21
+ # DatabaseSelector middleware is designed as such you can define your own
22
+ # strategy for connection switching and pass that into the middleware through
23
+ # these configuration options.
24
+ #
25
+ # Rails.application.configure do
26
+ # config.active_record.database_selector = { delay: 2.seconds }
27
+ # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
28
+ # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
29
+ # end
30
+ #
31
+ # Enable Shard Selector
32
+ #
33
+ # Inserts middleware to perform automatic shard swapping. The `shard_selector` hash
34
+ # can be used to pass options to the `ShardSelector` middleware. The `lock` option is
35
+ # used to determine whether shard swapping should be prohibited for the request.
36
+ #
37
+ # The `shard_resolver` option is used by the middleware to determine which shard
38
+ # to switch to. The application must provide a mechanism for finding the shard name
39
+ # in a proc. See guides for an example.
40
+ #
41
+ # Rails.application.configure do
42
+ # config.active_record.shard_selector = { lock: true }
43
+ # config.active_record.shard_resolver = ->(request) { Tenant.find_by!(host: request.host).shard }
44
+ # end
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.0.rc3
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-14 00:00:00.000000000 Z
11
+ date: 2021-12-15 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.0.rc3
19
+ version: 7.0.0
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.0.rc3
26
+ version: 7.0.0
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.0.rc3
33
+ version: 7.0.0
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.0.rc3
40
+ version: 7.0.0
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.
@@ -427,17 +427,19 @@ files:
427
427
  - lib/rails/generators/active_record/model/templates/abstract_base_class.rb.tt
428
428
  - lib/rails/generators/active_record/model/templates/model.rb.tt
429
429
  - lib/rails/generators/active_record/model/templates/module.rb.tt
430
+ - lib/rails/generators/active_record/multi_db/multi_db_generator.rb
431
+ - lib/rails/generators/active_record/multi_db/templates/multi_db.rb.tt
430
432
  homepage: https://rubyonrails.org
431
433
  licenses:
432
434
  - MIT
433
435
  metadata:
434
436
  bug_tracker_uri: https://github.com/rails/rails/issues
435
- changelog_uri: https://github.com/rails/rails/blob/v7.0.0.rc3/activerecord/CHANGELOG.md
436
- documentation_uri: https://api.rubyonrails.org/v7.0.0.rc3/
437
+ changelog_uri: https://github.com/rails/rails/blob/v7.0.0/activerecord/CHANGELOG.md
438
+ documentation_uri: https://api.rubyonrails.org/v7.0.0/
437
439
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
438
- source_code_uri: https://github.com/rails/rails/tree/v7.0.0.rc3/activerecord
440
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.0/activerecord
439
441
  rubygems_mfa_required: 'true'
440
- post_install_message:
442
+ post_install_message:
441
443
  rdoc_options:
442
444
  - "--main"
443
445
  - README.rdoc
@@ -450,12 +452,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
450
452
  version: 2.7.0
451
453
  required_rubygems_version: !ruby/object:Gem::Requirement
452
454
  requirements:
453
- - - ">"
455
+ - - ">="
454
456
  - !ruby/object:Gem::Version
455
- version: 1.3.1
457
+ version: '0'
456
458
  requirements: []
457
- rubygems_version: 3.2.15
458
- signing_key:
459
+ rubygems_version: 3.2.32
460
+ signing_key:
459
461
  specification_version: 4
460
462
  summary: Object-relational mapper framework (part of Rails).
461
463
  test_files: []