Commit Graph

88756 Commits

Author SHA1 Message Date
Eileen M. Uchitelle
ad83a66b70
Merge pull request #49116 from gmcgibbon/where_tuple_docs
Document tuple support in Active Record where clauses
2023-09-05 11:31:54 -04:00
Gannon McGibbon
6d165124cd [skip ci] Document tuple support in Active Record where clauses
Adds documentation to ActiveRecord::QueryMethods#where mentioning tuple
syntax support added in #47729.
2023-09-05 10:15:43 -05:00
Eileen M. Uchitelle
0f8377dd75
Merge pull request #49153 from Shopify/ar_querying_guide_cpk_example
Active Record querying guide: add a composite primary key example for find
2023-09-05 11:07:08 -04:00
Noah Gibbs
351f05579f
Active Record query guide: add a composite primary key example for find 2023-09-05 15:54:14 +01:00
Adrianna Chang
6633671e3a
Merge pull request #49150 from Shopify/rails_guides_updates_for_composite_primary_keys
Rails Guides: describe composite primary keys (CPK) for migrations and querying
2023-09-05 09:06:23 -04:00
Noah Gibbs
586c79d8b0
Mention composite primary keys for migrations and querying 2023-09-05 12:34:40 +01:00
Ryuta Kamizono
5fc58c86d2
Merge pull request #49148 from deepakmahakale/release_notes_7_1/minor_code_block_changes
[skip ci] Minor formatting fixes for code blocks
2023-09-05 19:54:04 +09:00
Ryuta Kamizono
1b0ee9f3f6
Merge pull request #49149 from deepakmahakale/release_notes_7_1/merge_rewhere_deprecated
[skip ci] rewhere argument on #merge deprecated
2023-09-05 19:53:04 +09:00
Deepak Mahakale
ba7def2e53 [skip ci] rewhere argument on #merge deprecated 2023-09-05 16:09:05 +05:30
Ryuta Kamizono
cf10924421
Merge pull request #49146 from kamipo/generating_token_only_once
Generate secure token only once regardless of `on: :initialize` or `on: :create`
2023-09-05 19:24:26 +09:00
Jean Boussier
11257c82ee
Merge pull request #49120 from akhilgkrishnan/simple-format-blank-wrapper
Fix: simple_format with blank wrapper_tag option returns plain html tag.
2023-09-05 12:17:49 +02:00
Deepak Mahakale
a16f1907ff [skip ci] Minor formatting fixes for code blocks 2023-09-05 15:40:56 +05:30
Akhil G Krishnan
1677e31240
Fix: simple_format with blank wrapper_tag option returns plain html tag.
By default `simple_format` method returns the text wrapped with `<p>`. But if we explicitly specify
the `wrapper_tag: nil` in the options, it returns the text wrapped with `<></>` tag.

Before:
```ruby
 simple_format("Hello World", {},  { wrapper_tag: nil })
 # <>Hello World</>
```

After:
```ruby
 simple_format("Hello World", {},  { wrapper_tag: nil })
 # <p>Hello World</p>
```

Co-authored-by: Junichi Ito <jit@sonicgarden.jp>
2023-09-05 10:09:40 +00:00
Ryuta Kamizono
a10e7a9dc5 Fix test_generating_token_on_initialize_does_not_affect_reading_from_the_column 2023-09-05 18:31:05 +09:00
Ryuta Kamizono
2a73ef8d3b Fix a test added in #48912 to work on a model with on: :initialize
Since default behavior is still `on: :create`.
2023-09-05 18:25:19 +09:00
Ryuta Kamizono
4f2fa59734 Don't modify existing test model in a test case
It will affect to other tests.
2023-09-05 18:12:33 +09:00
Ryuta Kamizono
2df70ddb96 Generate secure token only once regardless of on: :initialize or on: :create
Follow-up to #47420.

Whereas the original behavior (`on: :create`) is invoked only once
before a record is persisted, the new behavior (`on: :initialize`) is
invoked not only new record but also persisted records.

It should be invoked only once for new record consistently.
2023-09-05 17:43:41 +09:00
Ryuta Kamizono
2fbb25b771
Merge pull request #49133 from fatkodima/fix-has_secure_token-when-not-selected-column
Fix `has_secure_token on: :initialize` when column is not selected
2023-09-05 15:25:16 +09:00
Ryuta Kamizono
ca374bd9a3
Merge pull request #49136 from fatkodima/fix-counter-caches-var-modification
Fix in-place modification of shared `_counter_cache_columns` class attribute
2023-09-05 15:07:52 +09:00
Ryuta Kamizono
49314abc33
Merge pull request #49134 from fatkodima/fix-ar-tests-warnings
Fix `assert_deprecated` related warnings in ActiveRecord tests
2023-09-05 13:01:26 +09:00
Ryuta Kamizono
b32c8a04bd
Merge pull request #47865 from bensheldon/enqueue-error-message
Fix Active Job log message to correctly report a job failed to enqueue when the adapter raises an `ActiveJob::EnqueueError`
2023-09-05 12:16:58 +09:00
fatkodima
2933e16528 Fix in-place modification of shared _counter_cache_columns class attribute 2023-09-04 19:32:48 +03:00
fatkodima
72e3a3c9c1 Fix assert_deprecated related warnings in ActiveRecord tests 2023-09-04 16:25:20 +03:00
fatkodima
32f43176bb Fix has_secure_token on: :initialize when column is not selected 2023-09-04 15:55:57 +03:00
Petrik de Heus
42db7f307f
Merge pull request #49126 from tnir/tn-guide-remove-classic-from-engines
Simplify explanation by removing docs for classic mode
2023-09-04 10:31:08 +02:00
Ryuta Kamizono
8271186d01 Merge pull request #48095 from ippachi/triple-dot-range-unscope
Fix unscope not working when where by tripe dot range
2023-09-04 17:16:25 +09:00
Ryuta Kamizono
25379026fc
Merge pull request #49127 from kamipo/lock_globalid
Lock globalid gem version to address broken CI
2023-09-04 16:54:03 +09:00
Ryuta Kamizono
6440efa9ea Lock globalid gem version to address broken CI
Broken CI is due to https://github.com/rails/globalid/pull/163 in
globalid 1.2.0.

https://buildkite.com/rails/rails/builds/99329#018a5f01-a966-4424-9596-0a7f1deeb1ff/1178-1190
2023-09-04 16:40:19 +09:00
Vipul A M
f324203923
Merge pull request #49125 from akhilgkrishnan/remove-webpacker-reference
[skip ci] Remove webpacker guide reference
2023-09-04 12:51:34 +05:30
Ryuta Kamizono
532188cbf4
Merge pull request #45498 from HParker/deprecate-rewhere-on-merge
Deprecate passing `rewhere` to `merge`
2023-09-04 16:03:42 +09:00
Takuya Noguchi
258a908a0a Simplify explanation by removing docs for classic mode
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
2023-09-04 06:29:33 +00:00
Ryuta Kamizono
9084a9045f Add original author's credit for #49100 [ci-skip]
Since #41730 is the original work for the enum attribute validation.
2023-09-04 13:46:15 +09:00
Akhil G Krishnan
4631788d0f [skip ci] Remove webpacker guide reference 2023-09-04 09:37:03 +05:30
Guillermo Iguaran
bf9577e40c
Merge pull request #49123 from skipkayhil/hm-followup-49090
Remove $global mistakenly left in test
2023-09-03 17:53:05 -07:00
Vipul A M
31052d0e51
Merge pull request #49117 from akhilgkrishnan/general-async-release-note
[skip ci] Description added for `Active Record API for general async queries` in 7.1 release note
2023-09-03 22:17:32 +05:30
Hartley McGuire
db1a3537c7
Remove $global mistakenly left in test
This was accidentally left in when this change was [submitted][1] to
main. This was already addressed in the backport commit but this
addresses it for main.

[1]: 57a9e25f8e96eb28f4f3704db4be55bdb88c22f0
2023-09-02 12:27:50 -04:00
Ben Sheldon
b1b7debaa3
Fix Active Job log message to correctly report a job failed to enqueue when the adapter raises an ActiveJob::EnqueueError 2023-09-02 07:52:43 -07:00
Akhil G Krishnan
04e0b4bfc2 [skip ci] Description added for Active Record API for general async queries in 7.1 release note 2023-09-02 14:51:14 +05:30
Rafael Mendonça França
fea9ad3337
Make sure the message format doesn't change
When `use_message_serializer_for_metadata` is false, the message
format should be enveloped in the same way it was in Rails 7.0
to make sure we don't have inconsistent formats.
2023-09-01 23:03:24 +00:00
Rafael Mendonça França
ed873f1389
Merge pull request #49065 from RuhmUndAnsehen/fix-_to_partial_path-model_name
Fix ActiveModel::Conversion._to_partial_path not using a model's model_name.
2023-09-01 16:41:47 -04:00
Rafael Mendonça França
946550b467
Merge pull request #49067 from p8/performance/securerandom-choose
Use SecureRandom.alphanumeric for SecureRandom.base36/base58
2023-09-01 16:40:34 -04:00
Rafael Mendonça França
7459392bf1
Use the released version of trilogy 2023-09-01 20:39:50 +00:00
Rafael Mendonça França
a21c40bb70
Merge pull request #48912 from seanpdoyle/has-secure-token-default-on-initialize
Change `has_secure_token` default to `on: :initialize`
2023-09-01 16:29:57 -04:00
Sean Doyle
e85a3ec624
Change has_secure_token default to on: :initialize
Follow-up to [#47420][]

With the changes made in [#47420][], `has_secure_token` declarations can
be configured to execute in an `after_initialize` callback. This commit
proposed a new Rails 7.1 default: generate all `has_secure_token` values
when their corresponding models are initialized.

To preserve pre-7.1 behavior, applications can set
`config.active_record.generate_secure_token_on = :create`.

By default, generate the value when the model is initialized:

```ruby
class User < ApplicationRecord
  has_secure_token
end

record = User.new
record.token # => "fwZcXX6SkJBJRogzMdciS7wf"
```

With `config.active_record.generate_secure_token_on = :create`, generate
the value when the model is created:

```ruby
 # config/application.rb
config.active_record.generate_secure_token_on = :create

 # app/models/user.rb
class User < ApplicationRecord
  has_secure_token on: :create
end

record = User.new
record.token # => nil
record.save!
record.token # => "fwZcXX6SkJBJRogzMdciS7wf"
```

[#47420]: https://github.com/rails/rails/pull/47420

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
2023-09-01 20:17:22 +00:00
Eileen M. Uchitelle
3bc64016af
Merge pull request #49112 from gmcgibbon/cpk_id_docs
Composite Primary Key id method docs
2023-09-01 15:58:54 -04:00
Эдем
7c65a4b83b
Make enums validatable without raising error (#49100)
* Make enums validatable without raising error

* Trigger fail CI

Co-authored-by: Rafael Mendonça França <rafael@rubyonrails.org>
2023-09-01 15:31:12 -04:00
Gannon McGibbon
5ae1c5a812 [skip ci] Document id_value method
Adds documention for ActiveRecord::ModelSchema#id_value as a utility
when using composite primary keys.
2023-09-01 14:15:02 -05:00
Gannon McGibbon
362134b462 [skip ci] Document composite primary key behaviour
Adds documentation to exaplain composite key behaviour in
ActiveRecord::AttributeMethods::PrimaryKey for
methods #id, #id=, #id?, #id_before_type_cast, #id_was, #id_in_database.
2023-09-01 14:14:43 -05:00
Rafael Mendonça França
cdbc9b78cb
Merge pull request #49090 from skipkayhil/hm-change-column-precision-6
Fix change_column not setting precision for sqlite
2023-09-01 14:21:53 -04:00
Jean Boussier
9fd3d03dab
Merge pull request #49105 from Earlopain/ar-normalizes-where
Document `where` support for AR `normalizes`
2023-09-01 19:02:14 +02:00