Commit Graph

86975 Commits

Author SHA1 Message Date
Rafael Mendonça França
6aaa9db647
Merge pull request #46101 from swanson/swanson/missing-attachable-partial
Allow Attachables to override default template when attachment is missing
2023-03-25 12:49:54 -04:00
Rafael Mendonça França
0de99e92fd
Merge pull request #47313 from gregmolnar/stats
move directory existence check for code statistics task inside of the…
2023-03-25 12:21:46 -04:00
Rafael Mendonça França
c0a2292b0f
Merge pull request #47768 from eval/truncate-docs
Bring String#truncate* docs in line with signatures
2023-03-25 12:16:59 -04:00
Rafael Mendonça França
06a8427ec6
Merge pull request #47186 from zzak/rubocop-md
Rubocop markdown snippets
2023-03-25 11:27:47 -04:00
Rafael Mendonça França
acd8fd142d
Merge pull request #47758 from sled/security/set-content-type-charset
Set charset in content type response headers (OWASP)
2023-03-25 11:24:43 -04:00
Rafael Mendonça França
05104e82b8
Merge pull request #47732 from cmatheson/backburner-provider-job-id
implement `provider_job_id` for Backburner jobs
2023-03-25 11:21:40 -04:00
Rafael Mendonça França
166ef00399
Merge pull request #47737 from waymondo/encrypted-rich-text-load-hook
Add `ActiveSupport` load hook for `ActionText::EncryptedRichText`
2023-03-25 11:07:12 -04:00
Gert Goet
23674c5853 Bring truncate* docs in line with signatures 2023-03-25 15:49:07 +01:00
zzak
9f49959fee
Merge pull request #47766 from zzak/fix-actionpack-changelog-lint
Fix actionpack CHANGELOG lint error
2023-03-25 08:51:23 +09:00
zzak
57b01b4633
Fix actionpack CHANGELOG lint error 2023-03-25 08:32:26 +09:00
Rafael Mendonça França
338fcc37ae
Merge pull request #47764 from andrewn617/dont-change-behaviour-of-deprecated-fixture-path-method
`TestFixtures#fixture_path` should return a single path
2023-03-24 16:18:05 -04:00
Andrew Novoselac
a35a2d0d15 Fix an issue where TestFixtures#fixture_path was returning an array. It is deprecated, but it should still return a string until it is removed. So, if multiple fixture_paths are configured, it just returns the first path. 2023-03-24 15:42:24 -04:00
Eileen M. Uchitelle
995768e791
Merge pull request #47762 from Shopify/ar-calculations-ids-for-a-cpk-model
Fix `ActiveRecord::Calculations#ids` for a composite primary key model
2023-03-24 09:31:16 -04:00
Eileen M. Uchitelle
643b5a6c87
Merge pull request #47742 from Shopify/fix-query-constraints-association-from-a-non-query-constraints-model
Fix precedence of `primary_key:` in associations with `query_constraints`
2023-03-24 09:29:28 -04:00
Nikita Vasilevsky
1217127703 Fix ActiveRecord::Calculations#ids for a composite primary key model
Given a model with a composite primary key like:
`TravelRoute.primary_key = [:from, :to]`

Calling `TravelRoute.ids` would return an array of identifiers which is
represented by an array of arrays:

```ruby
TravelRoute.all.ids # => [["Ottawa", "New York"], ["London", "Paris"]]
```
2023-03-24 12:45:54 +00:00
zzak
824ef94092
Merge pull request #47760 from zzak/fix-health-controller-doc
Fix where HealthController doc gets parsed
2023-03-24 18:37:08 +09:00
zzak
2ab459a40c
Fix where HealthController doc gets parsed 2023-03-24 18:34:41 +09:00
Simon Schmid
a9d191997b set charset in content type response headers 2023-03-24 10:17:04 +01:00
zzak
af10abdc92
Merge pull request #47757 from zzak/api-doc-guide-code-samples
Document SQL and IRB comment styles
2023-03-24 18:06:56 +09:00
zzak
0dde0b56e7
Document SQL and IRB comment styles 2023-03-24 17:59:42 +09:00
Jean Boussier
ca195a8917
Merge pull request #47748 from Shopify/fix-race-condition-in-evented-file-update-checker
Fix a race condition in EventedFileUpdateCheckerTest
2023-03-24 09:57:31 +01:00
Cameron Matheson
0cb0880b1a implement provider_job_id for Backburner jobs 2023-03-23 19:19:34 -06:00
Nikita Vasilevsky
f29ff0f0a0 Fix precedence of primary_key: in associations with query_constraints 2023-03-23 23:01:06 +00:00
Guillermo Iguaran
097f703d59
Merge pull request #47749 from matteeyah/main
Extract sample rate in audio analyzer
2023-03-23 12:17:10 -07:00
Matija Čupić
c0465cf6aa
Extract sample rate in audio analyzer 2023-03-23 19:50:32 +01:00
Eileen M. Uchitelle
1aac4854f9
Merge pull request #47741 from Shopify/pm/cpk-rollback
Support composite primary keys during transaction rollback
2023-03-23 10:16:11 -04:00
Jean Boussier
dd722263ff Fix a race condition in EventedFileUpdateCheckerTest
Fix: https://github.com/rails/rails/pull/47746

We need to wait for the listener threads to exit.
2023-03-23 13:52:02 +01:00
Paarth Madan
996d5023f0 Support composite primary keys during transaction rollback 2023-03-22 19:16:05 -04:00
Eileen M. Uchitelle
2cef3ac45b
Merge pull request #47729 from Shopify/pm/cpk-where-syntax
Introduce query-by-tuple syntax
2023-03-22 17:08:42 -04:00
Vipul A M
047a76e37f
Merge pull request #47702 from shouichi/class-cache-nodoc
Add nodoc to ActiveRecord::FixtureSet::ClassCache [skip ci]
2023-03-23 01:54:01 +05:30
Paarth Madan
350b397917 Delete Cpk::Book in non-transactional test
Having this record persisted across test runs was leading to flakey behaviour in tests that were creating Cpk::Book with the same primary key.
2023-03-22 16:16:41 -04:00
justin talbott
beb43e0182
Add ActiveSupport load hook for ActionText::EncryptedRichText
Both `ActionText::Record` and `ActionText::RichText` have dedicated `ActiveSupport` load hooks. This adds an
additional hook for `ActionText::EncryptedRichText`, so that external libraries have a similarly simple way
to run code after the subclass is loaded.
2023-03-22 16:00:08 -04:00
Paarth Madan
77b9cddbbe Use tuple query syntax to avoid branching 2023-03-22 13:56:48 -04:00
Paarth Madan
e39e013cf7 Specify where clauses by mapping columns to tuples
With the introduction of composite primary keys, a common usecase is querying for records with tuples representing the composite key. This change introduces new syntax to the where clause that allows specifying an array of columns mapped to a list of corresponding tuples. It converts this to an OR-joined list of separate queries, similar to previous implementations that rely on grouping queries.
2023-03-22 13:56:47 -04:00
Jean Boussier
e55ccf0f10 Mark RaiseWarnings as :nodoc:
I didn't expect RDoc to document this code.
2023-03-22 18:38:23 +01:00
Eileen M. Uchitelle
355fd59290
Merge pull request #47731 from Shopify/fix-CPK-models-equality
Fix `#hash` and `#==` for composite pk models
2023-03-22 10:28:45 -04:00
Nikita Vasilevsky
7b1a617c21 Fix #hash and #== for composite pk models
Given a model with a composite primary key, for example:
`TravelRoute.primary_key = [:from, :to]`

and two objects of the given model, objects `a` and `b`, should be
equal to each other and have the same `hash` value if they have the same
values for the composite primary key, like:

```ruby
a = TravelRoute.new(from: "NYC", to: "LAX")
b = TravelRoute.new(from: "NYC", to: "LAX")
a == b # => true

a.hash == b.hash # => true
```

At the same time, two objects of the given model should not be equal to
each other and should have different `hash` values if they have
different primary key values or no primary key being set, like:

```ruby
a = TravelRoute.new(from: "NYC", to: "LAX")
b = TravelRoute.new(from: "NYC", to: "SFO")
a == b # => false
a.hash == b.hash # => false

TravelRoute.new == TravelRoute.new # => false
TravelRoute.new.hash == TravelRoute.new.hash # => false
```
2023-03-22 13:46:20 +00:00
Guillermo Iguaran
fedaf03ff7
Merge pull request #47728 from p8/docs/health-controller
Use explicit module for Rails::HealthController
2023-03-22 00:52:14 -07:00
Petrik
51c41796ba Use explicit module for Rails::HealthController
This makes sure it falls under the "Rails" section of the API sidebar.
2023-03-21 22:19:10 +01:00
Eileen M. Uchitelle
ba19dbc499
Merge pull request #47721 from Shopify/fix-nullifying-has-many-through-association
Fix nullification of has_many :through association with `query_constraints
2023-03-21 11:57:28 -04:00
Nikita Vasilevsky
300c853494 Fix nullification of has_many :through association with query_constraints
Given a `has_many :through` association with `query_constraints`:

```ruby
BlogPost.has_many :posts_tags
BlogPost.has_many :tags,
  through: :posts_tags,
  query_constraints: [:blog_id, :post_id]
``

It is possible to nullify the association like `blog_post.tags = []`
which results in deletion of records from the `posts_tags` joining table.
2023-03-21 13:51:30 +00:00
Eileen M. Uchitelle
4b183e4942
Merge pull request #47720 from Shopify/pm/cpk-id-accessor
Accept composite primary key in `id=`
2023-03-21 09:50:01 -04:00
Matthew Draper
05cb63abda
Merge pull request #47650 from nickborromeo/add-error-codes-to-warnings-ignore-list
Allow SQL Warnings to be ignored using error codes
2023-03-21 13:38:49 +10:30
Paarth Madan
10e86244ce Accept composite primary key in id= 2023-03-20 19:00:43 -04:00
Jonathan Hefner
d53dc86886
Merge pull request #47714 from nirebu/nirebu/stop-root-string-allocation-in-helper
Do not allocate the first path character in asset helper
2023-03-20 16:12:58 -05:00
Nick Borromeo
6bd100711c Allow SQL Warnings to be ignored using error codes
In https://github.com/rails/rails/pull/46690 the `db_warnings_action` and `db_warnings_ignore` configs where added. The
`db_warnings_ignore` can take a list of warning messages to match against.

At GitHub we have a subscriber that that does something like this but also filters out error codes. There might also be
other applications that filter via error codes and this could be something they can use instead of just the explicit
messages.

This also refactors the adapter tests in order for mysql2 and postgresql adapters to share the same helper when setting
the db_warnings_action and db_warnings_ignore configs
2023-03-20 13:06:22 -07:00
Matthew Draper
bc081a55be
Merge pull request #47715 from adrianna-chang-shopify/ac-pg-fix-conn-param
PostgreSQL adapter uses :host instead of :hostname for connection params
2023-03-21 04:27:38 +10:30
Adrianna Chang
b3d6c6496f
PostgreSQL adapter uses :host instead of :hostname for connection parameters 2023-03-20 13:09:10 -04:00
Nicolò Rebughini
a63ae913df Do not allocate the first path character in asset helper
In asset heavy views, the asset_path helper might be called a lot of
times. When checking the first character of the source element with []
we allocate a string each time just to check it against ?/.

By using String#start_with? we can avoid this step and go a bit faster.

This is the code I used to measure the change:

```

require "bundler/inline"

ROOT_STRING = '/'
TEST_PATH = "/some/path"

gemfile(true) do
  source "https://rubygems.org"

  gem "benchmark-ips"
end

Benchmark.ips do |x|
  x.report("source[0]") do
   TEST_PATH[0] != ROOT_STRING
  end

  x.report("source.start_with?") do
   TEST_PATH.start_with?(ROOT_STRING)
  end

  x.compare!
end
```

Warming up --------------------------------------
           source[0]   905.322k i/100ms
  source.start_with?     1.541M i/100ms
Calculating -------------------------------------
           source[0]      9.012M (± 0.7%) i/s -     45.266M in   5.022969s
  source.start_with?     15.395M (± 0.4%) i/s -     77.030M in   5.003691s

Comparison:
  source.start_with?: 15394807.0 i/s
           source[0]:  9012304.9 i/s - 1.71x  slower
2023-03-20 17:32:42 +01:00
Petrik de Heus
25f8d57100
Merge pull request #47712 from americos/patch-1 [ci-skip]
Fixing config generator in generators.md
2023-03-20 14:37:34 +01:00