| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Currently, if `:datetime` type has a precision, type casting always does
round off subseconds regardless of whether necessary or not, it is a bit
slow.
Since #34970, `t.timestamps` with `precision: 6` by default, so
`pluck(:created_at)` in newly created app will always be affected by the
round off.
This avoids the round off if possible, it makes `pluck(:created_at)`
about 25% faster.
https://gist.github.com/kamipo/e029539f2632aee9f5e711fe66fc8842
Before (0a87d7c9ddb95cf7568baf889ff4091469ba9af4 with postgresql adapter):
```
Warming up --------------------------------------
users.pluck(:id) 344.000 i/100ms
users.pluck(:name) 336.000 i/100ms
users.pluck(:created_at) 206.000 i/100ms
Calculating -------------------------------------
users.pluck(:id) 3.620k (± 8.5%) i/s - 18.232k in 5.077316s
users.pluck(:name) 3.579k (± 9.4%) i/s - 17.808k in 5.020230s
users.pluck(:created_at) 2.069k (± 8.0%) i/s - 10.300k in 5.019284s
```
Before (0a87d7c9ddb95cf7568baf889ff4091469ba9af4 with mysql2 adapter):
```
Warming up --------------------------------------
users.pluck(:id) 245.000 i/100ms
users.pluck(:name) 240.000 i/100ms
users.pluck(:created_at) 180.000 i/100ms
Calculating -------------------------------------
users.pluck(:id) 2.548k (± 9.4%) i/s - 12.740k in 5.066574s
users.pluck(:name) 2.513k (± 8.0%) i/s - 12.480k in 5.011260s
users.pluck(:created_at) 1.771k (±11.2%) i/s - 8.820k in 5.084473s
```
After (this change with postgresql adapter):
```
Warming up --------------------------------------
users.pluck(:id) 348.000 i/100ms
users.pluck(:name) 357.000 i/100ms
users.pluck(:created_at) 254.000 i/100ms
Calculating -------------------------------------
users.pluck(:id) 3.628k (± 8.2%) i/s - 18.096k in 5.024748s
users.pluck(:name) 3.624k (±12.4%) i/s - 17.850k in 5.020959s
users.pluck(:created_at) 2.567k (± 7.0%) i/s - 12.954k in 5.081153s
```
After (this change with mysql2 adapter):
```
Warming up --------------------------------------
users.pluck(:id) 268.000 i/100ms
users.pluck(:name) 265.000 i/100ms
users.pluck(:created_at) 207.000 i/100ms
Calculating -------------------------------------
users.pluck(:id) 2.586k (±10.9%) i/s - 12.864k in 5.050546s
users.pluck(:name) 2.543k (±10.2%) i/s - 12.720k in 5.067726s
users.pluck(:created_at) 2.263k (±14.5%) i/s - 10.971k in 5.004039s
```
|
|/ / / / / |
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Allow symbol (i.e. quoted identifier) as safe SQL string
|
| | |/ / /
| |/| | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
`pluck(:id)` / `order(:id)` are very common use case, and passed symbol
(i.e. quoted identifier) is obviously safe argument, but
`:id.to_s.split(/\s*,\s*/).all? { |part| permit.match?(part) }` is
useless and a bit expensive operation for each such safe symbols (will
make extra 2 mutable strings, 1 array, 1 proc).
This avoids the expensive operation to such safe symbols, it makes
`pluck(:id)` / `order(:id)` itself about 9% faster.
https://gist.github.com/kamipo/11d428b57f3629a72ae89c6f21721326
Before (93e640735e9363672b770b8d1c5a35f9e464f806):
```
Warming up --------------------------------------
users.pluck(:id) 1.217k i/100ms
users.order(:id).to_sql 1.848k i/100ms
Calculating -------------------------------------
users.pluck(:id) 12.239k (± 8.2%) i/s - 60.850k in 5.013839s
users.order(:id).to_sql 19.111k (± 7.5%) i/s - 96.096k in 5.064450s
```
After (this change):
```
Warming up --------------------------------------
users.pluck(:id) 1.293k i/100ms
users.order(:id).to_sql 2.036k i/100ms
Calculating -------------------------------------
users.pluck(:id) 13.257k (± 6.9%) i/s - 65.943k in 5.002568s
users.order(:id).to_sql 20.957k (± 7.6%) i/s - 105.872k in 5.086102s
```
|
|\ \ \ \ \
| | | | | |
| | | | | |
| | | | | | |
[documentation][ci skip] stringify_keys and symbolize_keys have stable results.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Rails 6 uses the `Hash.transform_keys` found in Ruby 2.5 and later, and that method enumerates keys based on insertion order. Calling `symbolize_keys`, `stringify_keys`, and their bang variants will result in the same hash every time -- the value for any key where a collision occurs is the last assigned in that enumeration
In the docs for Hash -- https://ruby-doc.org/core-2.5.0/Hash.html
> Hashes enumerate their values in the order that the corresponding keys were inserted.
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
Remove unused requires from debug_exceptions
|
|/ / / / / / |
|
|\ \ \ \ \ \
| |/ / / / /
|/| | | | | |
[documentation][ci skip] changes 'Week day' to 'day of week'
|
|/ / / / /
| | | | |
| | | | |
| | | | |
| | | | | |
'Week day' has a specific meaning in English -- see https://en.wiktionary.org/wiki/weekday for details -- that is not meant here. 'Day of week' is more appropriate.
[ci skip]
|
| | | | | |
|
|\ \ \ \ \
| |/ / / /
|/| | | | |
Use WeakRef in Reaper to avoid leaking connection pools
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Prior to 3e2e8eeb9ea552bd4782538cf9348455f3d0e14a the Reaper thread
would hold a reference to connection pools indefinitely, preventing the
connection pool from being garbage collected, and also leaking the
Thread.
Since 3e2e8eeb9ea552bd4782538cf9348455f3d0e14a, there is only one Reaper
Thread for all pools, however all pools are still stored in a class
variable, preventing them from being garbage collected.
This commit instead holds reference to the pools through a WeakRef. This
way, connection pools referenced elsewhere will be reaped, any others
will be able to be garbage collected.
I don't love resorting to WeakRef to solve this, but I believe it's the
simplest way to accomplish the the desired behaviour.
|
| | | | |
|
| | | | |
|
|\ \ \ \
| | | | |
| | | | |
| | | | |
| | | | | |
Change comments
[ci skip]
|
|/ / / / |
|
|\ \ \ \
| | | | |
| | | | | |
Fix EventedFileUpdateChecker through a symlink
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
On MacOS, Dir.tmpdir gives me a folder inside "/var/folders/". However,
/var is a symlink to /private/var.
Previously, the nonexistent directory test would fail because it was
initialized with /var/folders/... but the filenames from listen would be
the realpaths.
This commit normalizes the dirs by calling realpath on them if they
exist. This is done on boot!, so it will work with newly directories
through the symlink.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
The common include of this test creates a tmpdir, we should use that for
consistency.
|
| | | | | |
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Wrap ActionView cache expiry in a mutex
|
| | | | | | |
|
|\ \ \ \ \ \
| |_|/ / / /
|/| | | | | |
Delete evented_file_update_checker existing_parent
|
|/ / / / /
| | | | |
| | | | |
| | | | | |
This is no longer used as of caa3cc8868206f8109e0d633efb09d31e94ef635
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Bump Gemfile entry jbuilder version
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
jbuilder 2.6.4 is the first version that relaxes the version constraint to allow
Rails 6. I also did some more tests in #25183, although not with 2.6.4
explicitly.
To simplify the version requirement, I went for 2.7.
https://github.com/rails/jbuilder/blob/v2.6.4/jbuilder.gemspec
https://github.com/rails/rails/issues/25183#issuecomment-494342406
|
|\ \ \ \ \ \
| |/ / / / /
|/| | | | | |
Add :allow_nil option to delegate_missing_to
|
|/ / / / /
| | | | |
| | | | |
| | | | | |
attachment
|
|\ \ \ \ \
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
albertoalmagro/path_helper_without_params_does_not_loose_scope
Keep part when scope option has value
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
After @kamipo CR feedback we realized `Route#build` wasn't used. As it
is also private API being able to create Routes both with `#new` and
`#build` was redundant.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
This commit changes from constructor's argument list to keyword
arguments in order to remove the dependency of remember parameters'
positions.
It also unifies all parameters extracted from the `scope` into
`scope_params`, which also takes care of providing the default values
for them.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
This commit changes from constructor's argument list to keyword
arguments in order to remove the dependency of remember parameters'
positions.
The constructor already provided a default value for `internal`, this
commits takes the chance to also add default values for `precedence` and
`scope_options`.
|
|/ / / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
When a route was defined within an optional scope, if that route didn't
take parameters the scope was lost when using path helpers. This patch
ensures scope is kept both when the route takes parameters or when it
doesn't.
Fixes #33219
|
| | | | | |
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Remove compatibility module from docs [ci skip]
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
This module exists to warn old users. I think we should remove
it from the docs so we don't advertise it.
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
gustavogr/add-deep-transform-keys-to-strong-params
Added deep_transform_keys to StrongParameters
|
|/ / / / / / |
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
[ci skip] (#36326)
- This hook was added in 90296674b1c
|
|\ \ \ \ \ \
| |_|/ / / /
|/| | | | | |
[CI skip] Put :nodoc: on method that raises NoMethodError
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
This method is not intended to be used so I think we should
remove it from the docs.
|
| |/ / / /
|/| | | |
| | | | |
| | | | | |
And no longer need to except SCHEMA SQLs manually since 0810c07.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This reverts commit a1ee4a9ff9d4a3cb255365310ead0dc7b739c6be.
Even if a1ee4a9 is applied, CI is still flakiness.
https://buildkite.com/rails/rails/builds/61252#2c090afa-aa84-4a2b-8b81-9f09219222c6/994-1005
https://buildkite.com/rails/rails/builds/61252#2e55bf83-1bde-44a2-a4f1-b5c3f6820fb4/929-938
Failing tests by whether schema cache is filled or not, it actually
means that whether SCHEMA SQLs are executed or not is not target for the
tests.
So I've reverted commit a1ee4a9 which filling schema cache before
`assert_no_queries`, and replace `assert_no_queries` to
`assert_queries(0)`.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Almost all database statements methods except `explain` was moved into
`DatabaseStatements` at #35922. This moves the last one method.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Fall back to type casting from the connection adapter
|
|/ / / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Unfortunately, a11a8ff had no effect as long as using bind param, and
was not tested.
This ensures making the intent of a11a8ff, which fall back to type
casting from the connection adapter.
Fixes #35205.
```
% ARCONN=postgresql bundle exec ruby -w -Itest test/cases/relation/where_test.rb -n test_type_casting_nested_joins
Using postgresql
Run options: -n test_type_casting_nested_joins --seed 55730
# Running:
E
Error:
ActiveRecord::WhereTest#test_type_casting_nested_joins:
ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "2-foo"
rails test test/cases/relation/where_test.rb:30
Finished in 0.245778s, 4.0687 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
```
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Testing the result of `capture_sql` is fragile, it is due to whether
SCHEMA SQLs are executed or not depends on whether schema cache is
filled or not.
https://buildkite.com/rails/rails/builds/61248#a5b9dc59-ff0c-40c0-b56e-0895662fbc4c/993-1004
https://buildkite.com/rails/rails/builds/61248#1157b389-f2c7-4554-b6e5-a37624a0e74a/996-1005
I've confirmed all `capture_sql` use cases in our code base, all cases
won't expect SCHEMA SQLs are included.
```
% git grep -n capture_sql
test/cases/associations/belongs_to_associations_test.rb:202: sql = capture_sql { comment.post }
test/cases/associations/belongs_to_associations_test.rb:204: assert_not_equal sql, capture_sql { comment.post }
test/cases/associations/has_many_associations_test.rb:169: sql = capture_sql { post.comments.to_a }
test/cases/associations/has_many_associations_test.rb:171: assert_not_equal sql, capture_sql { post.comments.to_a }
test/cases/associations/has_many_associations_test.rb:276: expected_sql = capture_sql { author.thinking_posts.delete_all }
test/cases/associations/has_many_associations_test.rb:281: loaded_sql = capture_sql { author.thinking_posts.delete_all }
test/cases/associations/has_many_associations_test.rb:289: expected_sql = capture_sql { author.posts.delete_all }
test/cases/associations/has_many_associations_test.rb:294: loaded_sql = capture_sql { author.posts.delete_all }
test/cases/associations/left_outer_join_association_test.rb:22: queries = capture_sql do
test/cases/associations/left_outer_join_association_test.rb:49: queries = capture_sql { Author.left_outer_joins(:posts).to_a }
test/cases/associations/left_outer_join_association_test.rb:54: queries = capture_sql { Author.joins(:posts).left_outer_joins(:posts).to_a }
test/cases/associations/left_outer_join_association_test.rb:60: queries = capture_sql { Author.left_outer_joins({}).to_a }
test/cases/associations/left_outer_join_association_test.rb:65: queries = capture_sql { Author.left_outer_joins([]).to_a }
test/cases/associations/left_outer_join_association_test.rb:78: queries = capture_sql { Author.left_outer_joins(:essays).to_a }
test/cases/associations_test.rb:384: log = capture_sql do
test/cases/associations_test.rb:399: log = capture_sql do
test/cases/associations_test.rb:414: log = capture_sql do
test/cases/associations_test.rb:429: log = capture_sql do
test/cases/associations_test.rb:444: log = capture_sql do
test/cases/associations_test.rb:459: log = capture_sql do
test/cases/reflection_test.rb:307: expected_sql = capture_sql { hotel.recipes.to_a }
test/cases/reflection_test.rb:312: loaded_sql = capture_sql { hotel.recipes.to_a }
test/cases/relation_test.rb:212: queries = capture_sql { Author.joins(:posts).merge(Post.joins(:comments)).to_a }
test/cases/relation_test.rb:232: queries = capture_sql { Post.joins(:author, :categorizations).merge(Author.select(:id)).merge(categorizations_with_authors).to_a }
test/cases/relation_test.rb:347: log = capture_sql do
test/cases/scoping/relation_scoping_test.rb:146: log = capture_sql do
test/cases/scoping/relation_scoping_test.rb:159: log = capture_sql do
test/cases/test_case.rb:33: def capture_sql
test/cases/test_case.rb:41: capture_sql { yield }
```
|
| | | | | |
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Correct human file size examples [ci skip]
|