Commit Graph

87396 Commits

Author SHA1 Message Date
Jon Dufresne
38ee087262 Fix typo: has -> hash 2023-04-15 07:28:33 -07:00
Eileen M. Uchitelle
881ea9db87
Merge pull request #47947 from Shopify/pm/fixtures-with-composite-key
Support building fixtures with associations that use CPK
2023-04-15 08:12:26 -04:00
Xavier Noria
bb6eb87be2 User a relative link here 2023-04-15 13:05:26 +02:00
Xavier Noria
6cbd2c97ed Document config.rake_eager_load in the autoloading guide 2023-04-15 13:03:00 +02:00
Guillermo Iguaran
c5079e47b2
Merge pull request #47933 from renny-ren/update-sse-docs
Update docs about SSE streaming response
2023-04-15 01:56:33 -07:00
Guillermo Iguaran
c493712fb1
Merge pull request #47950 from skipkayhil/hm-fix-skip-active-job-development
Fix NoMethodError in dev.rb when skip-active-job
2023-04-15 01:44:24 -07:00
Hartley McGuire
9a297fb936
Fix NoMethodError in dev.rb when skip-active-job
config.active_jobs.verbose_enqueue_logs was [added][1] to the
development.rb template, but it was put inside the skip-active-record
block. This means that it will be included in generated development.rb
even when Active Job is skipped.

This commit fixes this issue by moving it outside of the
skip-active-record check and into its own skip-active-job check.

[1]: f6d56fed27cfd11aa7161129e2c59a972f90b76b
2023-04-15 01:22:31 -04:00
Akshay Birajdar
7da4f7ffd4 Implement #inspect for file & null cache store 2023-04-15 09:09:58 +05:30
Vipul A M
ccb646244f
Merge pull request #47949 from wagner/fixtureset-identify
Adds documentation for the FixtureSet#identify when the identifier is a UUID
2023-04-15 04:16:50 +05:30
Wagner Narde
6f8b5f8a89
Adds documentation for the FixtureSet#identify when the identifier is a UUID 2023-04-14 19:32:16 -03:00
Paarth Madan
3d820195a0 Support fixture associations for composite models
Most of the support here is in implementing how to correctly substitute
multiple values in place of one, for composite caes. In composite cases,
it's not sufficient to hash a label into a single integer value.
Instead, we build an API that accepts a single label, and a list of
columns that we'd like to map to. The algorithm used internally is very
similar to #identify, with an additional bit shift and modulo to cycle
the hash and ensure it doesn't exceed a max.
2023-04-14 18:12:18 -04:00
fatkodima
11aaa3db6c Restore ability to redefine column in create_table for Rails 5.2 2023-04-15 00:32:12 +03:00
Eileen M. Uchitelle
ece21c71cc
Merge pull request #47946 from sampatbadhe/patch-6
Correct SQL query in where.not docs [ci skip]
2023-04-14 13:32:02 -04:00
sampatbadhe
5c79b0af2d Correct SQL query in where.not docs [ci skip] 2023-04-14 20:46:24 +05:30
Eileen M. Uchitelle
444df0eee1
Merge pull request #47935 from fatkodima/fix-broken-tests
Require missing CPK models in `base_test.rb` and `calculations_test.rb`
2023-04-13 13:17:38 -04:00
fatkodima
c8438fa998 Require missing CPK models in base_test.rb and calculations_test.rb 2023-04-13 19:49:16 +03:00
Eileen M. Uchitelle
1d7f4e65d6
Merge pull request #47928 from Shopify/pm/cpk-delete
Support deleting records from associations for CPK
2023-04-13 08:53:57 -04:00
Renny Ren
80c6cd871a Update docs about SSE streaming response 2023-04-13 18:13:49 +08:00
zzak
b20defada3
Merge pull request #47931 from zzak/re-47877
💅 Clean up changelog entry for #47877
2023-04-13 09:46:46 +09:00
zzak
fdd0cb8b04
💅 Clean up changelog entry for #47877 2023-04-13 09:40:52 +09:00
zzak
767653ab10
Merge pull request #47929 from jetjodh/patch-1
fixed comment for example sql statement
2023-04-13 07:34:02 +09:00
Jodh Singh
98e39b8a1b
fixed comment for example sql statement
Ref issue:
https://github.com/rails/rails/issues/47903
2023-04-12 18:07:59 -04:00
Paarth Madan
6afc035cbc Support deleting records from associations for CPK 2023-04-12 17:53:20 -04:00
Eileen M. Uchitelle
385903754e
Merge pull request #47925 from eileencodes/ensure-ids_writer-and-ids_reader-accomodate-cpk
Ensure that ids_writer and ids_reader is working for CPK
2023-04-12 16:21:24 -04:00
Eileen M. Uchitelle
12fc98fdbb
Merge pull request #47924 from Shopify/fix-autosave-for-models-assoc-with-a-cpk-model
Fix replacing foreign key for a CPK association by id attribute
2023-04-12 15:15:35 -04:00
eileencodes
885bd850e3
Ensure that ids_writer and ids_reader is working for CPK
This fixes `ids_writer` so that it can handle a composite primary key.
Using a CPK model associated with a non-CPK model was working correctly
(which I added a test for). Using a CPK model associated with another
CPK model was not working correctly. It now takes it into account to
write the correct ids.

While working on `ids_reader` I found that `pluck` is not working for
CPK because it's passing an array of attributes and that's not supported
by `disallow_raw_sql!`. I chose to call `flatten` in `pluck` but not
conditionally because this seems like it could be a problem elsewhere as
well. This fixes pluck by CPK overall and fixes a test in the
calculations test file.
2023-04-12 15:02:58 -04:00
Nikita Vasilevsky
c0da60f4c0 Fix replacing foreign key for a CPK association by id attribute
Given a model associated with a composite primary key by `id` attribute,
for example:
```ruby
Order.primary_key = [:shop_id, :id]
OrderAgreement.primary_key = :id

OrderAgreement.belongs_to :order, primary_key: :id
```

Assigning `order` to an `OrderAgreement` object will replace the
`order_id` foreign key:

```ruby
order = Order.last # => #<Order id: 1, shop_id: 2>

order_agreement = OrderAgreement.new(order: order).save
order_agreement.order_id # => 1
```
2023-04-12 18:53:54 +00:00
Eileen M. Uchitelle
3d4dd9fff2
Merge pull request #47923 from Shopify/fix-belongs-to-cpk-by-id-attr-association
Fix associations associated with a CPK model by id attribute
2023-04-12 12:39:22 -04:00
Nikita Vasilevsky
5cbdfba670 Fix associations associated with a CPK model by id attribute
Given a model associated with a composite primary key by `id` attribute,
for example:
```ruby
Order.primary_key = [:shop_id, :id]
OrderAgreement.primary_key = :id

Order.has_many :order_agreements, primary_key: :id
```

Accessing the association should perform queries using
the `id` attribute value and not the `id` as Order's composite primary key.

```ruby
order = Order.last # => #<Order id: 1, shop_id: 2>

order.order_agreements.to_a
```
2023-04-12 16:02:24 +00:00
Vipul A M
bcc2e0c4e4
Merge pull request #47921 from luanzeba/route_source_changelog
Changelog entry for routes source location
2023-04-12 20:45:21 +05:30
Luan Vieira
a154a08f2b
Changelog entry for routes source location
Change made in https://github.com/rails/rails/pull/47877
2023-04-12 10:54:40 -04:00
Matthew Draper
e11ebc04cf
Merge pull request #47889 from aharpole/fix-foreign-key-infinite-recursion
fix infinite recursion with foreign_key
2023-04-12 19:22:21 +09:30
Aaron Patterson
32819c5bcf
Merge pull request #47920 from aharpole/fix-none-relation-performing-query
Ensure `none` constraint scopes don’t trigger a query
2023-04-11 15:56:05 -07:00
Aaron Harpole
c210600846 Ensure none constraint scopes don’t trigger a query
#47800 refactored how `Relation#none` worked, and one side effect of this change was that if you had an association like this:

`has_many :comments_none, ->(post) { none }, class_name: "Comment”`

reading the association caused a query to happen, despite the `none` in the passed in scope.

As it turns out, this is because the association performs a merge of the two scopes, and the `@none` instance variable wasn’t getting copied over to the merged scope, so the upfront guard clause checking `@none` in `#exec_main_query`.

Updating the `Merger` object to add a check for null relations and call `none!` ensures the query doesn’t run in this particular scenario.
2023-04-11 15:09:46 -07:00
Guillermo Iguaran
1d22ea8f84
Merge pull request #47801 from p8/railties/deprecate-all-secrets-commands
Remove deprecated `secrets:setup` and deprecate `secrets:edit/show`
2023-04-11 14:52:46 -07:00
Jonathan Hefner
50189c46d3 Simplify reference links [ci-skip]
These references will be properly linked even without the fully
qualified module name.
2023-04-11 16:36:53 -05:00
Jonathan Hefner
2c371c67b7 Linkify code references [ci-skip]
Follow-up to #47354.
2023-04-11 16:28:31 -05:00
Jonathan Hefner
d9037d0b9f
Merge pull request #47919 from jonathanhefner/deprecators-rename-rails-as-railties
Rename `:rails` deprecator as `:railties`
2023-04-11 16:06:46 -05:00
Jonathan Hefner
0fc57a41a4 Rename :rails deprecator as :railties
Follow-up to #46049 and #47354.

Since `Rails.deprecator` is now a new `ActiveSupport::Deprecation`
instance instead of `ActiveSupport::Deprecation.instance`, it makes
sense to register it as `Rails.application.deprecators[:railties]`
instead of `Rails.application.deprecators[:rails]`.
2023-04-11 15:47:43 -05:00
Aaron Patterson
2675c906b1
Merge pull request #47877 from luanzeba/route-source-location
Print source location when inspecting routes
2023-04-11 11:58:47 -07:00
Jean Boussier
be287ac0d5
Merge pull request #47915 from javierav/feature/dockerfile-skip-options
Improve Dockerfile generation when use some skip options
2023-04-11 17:00:15 +02:00
Julius Rickert
965f6d4e03
Set fully qualified reference name for base image (#47888)
Explicitly set the fully qualified reference name to avoid issues in
environments which set a different default registry.
The registry at registry.docker.com is dual stack-compatible.
2023-04-11 15:48:18 +02:00
Eileen M. Uchitelle
23fdde8817
Merge pull request #47901 from fatkodima/batches-composite-pks
Support batching using composite primary keys
2023-04-11 08:36:39 -04:00
Javier Aranda
08cb03127e
Improve Dockerfile when use some skip options 2023-04-11 12:40:23 +02:00
Guillermo Iguaran
c396d97535
Merge pull request #47908 from platanus/update-app-generator
Use triple-dot delegation in AppGenerator
2023-04-10 22:44:49 -07:00
fatkodima
52f27f987e Support batching using composite primary keys 2023-04-10 21:36:54 +03:00
Vasiliy Ermolovich
bbb13631f8 Fix delegation to a method with implicit block.
When 8b2f57dc6f was
introduced it broke delegation of a method with implicit block like this:

```ruby
class Foo
  def self.bar
    yield
  end
end

class Bar
  delegate :bar, to: Foo
end

Bar.new.bar { } # raises LocalJumpError: no block given (yield)
```

It happens because it's impossible to detect a method with implicit block and
we rely on method's parameters when we generate delegated methods.

I've found only one solution to this issue: we always generate a method that explicitly accepts
block. It kind of makes sense since evey Ruby method accepts block implicitly anyway.

Fixes https://github.com/rails/rails/issues/47624
2023-04-10 19:28:26 +02:00
Guillermo Moreno
c42b62f3a1 Use triple-dot delegation in AppGenerator 2023-04-10 12:02:00 -04:00
Jean Boussier
c2a25803dd
Merge pull request #47891 from ghiculescu/expires_in-warning
Cache: warning if `expires_in` is given an incorrect value
2023-04-10 17:02:07 +02:00
Ryuta Kamizono
79f5d9965c
Merge pull request #47905 from hachi8833/fix_url_asset_pipeline_guide
Docs: Fix link to configuring.html#config-assets-paths [ci-skip]
2023-04-10 22:54:02 +09:00