- Nov 21, 2024
-
-
Jean Boussier authored
Redesign ActionView::Template::Handlers::ERB.find_offset to handle edge cases
-
Martin Emde authored
The code for finding offsets in the ERB templates outright fails in some cases, causing 500s in the error template. In other cases it will bail out early when it's possible to find and highlight correctly. This PR fixes many of the issues that regularly occur and correctly highlights more often. Also adds test coverage of the translate_location method on ActionView::Template, many of which failed before this fix.
-
Jean Boussier authored
Fix Mysql2Adapter support for prepared statements
-
Jean Boussier authored
Fix: https://github.com/rails/rails/issues/53673 Performing a query with prepared statements using the Mysql2 adapter would result in `NoMethodError`. Co-Authored-By:
Leo Arnold <github@leoarnold.de>
-
Ryuta Kamizono authored
Correct misformatted reference to `config/initializers/new_framework_defaults_*.rb` [ci skip]
-
Junichi Sato authored
-
Ryuta Kamizono authored
Allow passing Symbols as aliases in Arel
-
Benedikt Deicke authored
Table names, column names, and table aliases all allow symbols. This brings back symbol support for `#as` on nodes for consistency with these other methods.
-
Ryuta Kamizono authored
Fix task `abort_if_pending_migrations` to not use the return value from `Array#flatten!`
-
zzak authored
-
zzak authored
-
- Nov 20, 2024
-
-
Mike Dalessio authored
to mutate the array. We shouldn't be using the return value, which is `nil` if the array is unchanged.
-
Ryuta Kamizono authored
Ensure previously_new_record? is preserved in #becomes
-
- Nov 19, 2024
-
-
a5-stable authored
-
Ryuta Kamizono authored
Fix "Test is missing assertions" is caught by Strict Warnings
-
Ryuta Kamizono authored
Properly reset composite primary key configuration when setting a primary key
-
- Nov 18, 2024
-
-
zzak authored
``` $ RAILS_STRICT_WARNINGS=1 bin/test \ test/application/generators_test.rb \ test/application/initializers/frameworks_test.rb \ test/application/loading_test.rb \ test/application/rake/tmp_test.rb \ test/application/rake_test.rb Run options: --seed 7309 .............................Test is missing assertions: `test_tmp:clear_should_work_if_folder_missing` /home/zzak/code/rails/railties/test/application/rake/tmp_test.rb:41 E Error: ApplicationTests::RakeTests::TmpTest#test_tmp:clear_should_work_if_folder_missing: ActiveSupport::RaiseWarnings::WarningError: Test is missing assertions: `test_tmp:clear_should_work_if_folder_missing` /home/zzak/code/rails/railties/test/application/rake/tmp_test.rb:41 /home/zzak/code/rails/activesupport/lib/active_support/testing/strict_warnings.rb:38:in `warn' bin/test test/application/rake/tmp_test.rb:41 Test is missing assertions: `test_ARGV_is_populated` /home/zzak/code/rails/railties/test/application/generators_test.rb:180 E Error: ApplicationTests::GeneratorsTest#test_ARGV_is_populated: ActiveSupport::RaiseWarnings::WarningError: Test is missing assertions: `test_ARGV_is_populated` /home/zzak/code/rails/railties/test/application/generators_test.rb:180 /home/zzak/code/rails/activesupport/lib/active_support/testing/strict_warnings.rb:38:in `warn' bin/test test/application/generators_test.rb:180 ......Test is missing assertions: `test_can_boot_with_an_unhealthy_database` /home/zzak/code/rails/railties/test/application/initializers/frameworks_test.rb:219 E Error: ApplicationTests::FrameworksTest#test_can_boot_with_an_unhealthy_database: ActiveSupport::RaiseWarnings::WarningError: Test is missing assertions: `test_can_boot_with_an_unhealthy_database` /home/zzak/code/rails/railties/test/application/initializers/frameworks_test.rb:219 /home/zzak/code/rails/activesupport/lib/active_support/testing/strict_warnings.rb:38:in `warn' bin/test test/application/initializers/frameworks_test.rb:219 ...............................Test is missing assertions: `test_loading_only_yml_fixtures` /home/zzak/code/rails/railties/test/application/rake_test.rb:202 E Error: ApplicationTests::RakeTest#test_loading_only_yml_fixtures: ActiveSupport::RaiseWarnings::WarningError: Test is missing assertions: `test_loading_only_yml_fixtures` /home/zzak/code/rails/railties/test/application/rake_test.rb:202 /home/zzak/code/rails/activesupport/lib/active_support/testing/strict_warnings.rb:38:in `warn' bin/test test/application/rake_test.rb:202 ...Test is missing assertions: `test_models_without_table_do_not_panic_on_scope_definitions_when_loaded` /home/zzak/code/rails/railties/test/application/loading_test.rb:82 E Error: LoadingTest#test_models_without_table_do_not_panic_on_scope_definitions_when_loaded: ActiveSupport::RaiseWarnings::WarningError: Test is missing assertions: `test_models_without_table_do_not_panic_on_scope_definitions_when_loaded` /home/zzak/code/rails/railties/test/application/loading_test.rb:82 /home/zzak/code/rails/activesupport/lib/active_support/testing/strict_warnings.rb:38:in `warn' bin/test test/application/loading_test.rb:82 ``` This doesn't fail in CI because the warning is using a relative path: ``` Test is missing assertions: `test_tmp:clear_should_work_if_folder_missing` test/application/rake/tmp_test.rb:41 ``` Ref: https://buildkite.com/rails/rails/builds/113871#01933e25-4b3c-47f9-9b74-ea4ac84c6ae2/1292-1298 This can be reproduced locally like so: ``` RAILS_STRICT_WARNINGS=true ruby -w -Itest -Ilib -I../activesupport/lib -I../actionpack/lib -I../actionview/lib -I../activemodel/lib test/application/rake/tmp_test.rb /home/zzak/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/bundler-2.5.16/lib/bundler/rubygems_ext.rb:250: warning: method redefined; discarding old encode_with /home/zzak/.rbenv/versions/3.3.6/lib/ruby/3.3.0/rubygems/dependency.rb:341: warning: previous definition of encode_with was here Run options: --seed 35733 Test is missing assertions: `test_tmp:clear_should_work_if_folder_missing` /home/zzak/code/rails/railties/test/application/rake/tmp_test.rb:41 E. Finished in 0.118110s, 16.9334 runs/s, 33.8668 assertions/s. 1) Error: ApplicationTests::RakeTests::TmpTest#test_tmp:clear_should_work_if_folder_missing: ActiveSupport::RaiseWarnings::WarningError: Test is missing assertions: `test_tmp:clear_should_work_if_folder_missing` /home/zzak/code/rails/railties/test/application/rake/tmp_test.rb:41 /home/zzak/code/rails/activesupport/lib/active_support/testing/strict_warnings.rb:38:in `warn' 2 runs, 4 assertions, 0 failures, 1 errors, 0 skips ```
-
fatkodima authored
-
Ryuta Kamizono authored
Merge pull request #53626 from viralpraxis/add-actiondispatch-request-session-store-method-to-conform-rack-spec Add `ActionDispatch::Request::Session#store` method to conform Rack spec
-
viralpraxis authored
Rack specification states that a hash-like object stored in environment with `rack.session` key MUST implement `store/2` method. Without the alias, this test fails with the following: ``` Exception while processing request: Rack::Lint::LintError: session #<ActionDispatch::Request::Session:0x3570 not yet loaded> must respond to store and []= /home/zzak/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rack-3.1.8/lib/rack/lint.rb:206:in `check_environment' /home/zzak/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rack-3.1.8/lib/rack/lint.rb:63:in `response' /home/zzak/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rack-3.1.8/lib/rack/lint.rb:41:in `call' lib/action_dispatch/middleware/cookies.rb:706:in `call' /home/zzak/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rack-session-2.0.0/lib/rack/session/abstract/id.rb:272:in `context' /home/zzak/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rack-session-2.0.0/lib/rack/session/abstract/id.rb:266:in `call' /home/zzak/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rack-3.1.8/lib/rack/head.rb:15:in `call' /home/zzak/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rack-3.1.8/lib/rack/method_override.rb:28:in `call' lib/action_dispatch/middleware/cookies.rb:706:in `call' lib/action_dispatch/middleware/callbacks.rb:31:in `block in call' /home/zzak/code/rails/activesupport/lib/active_support/callbacks.rb:100:in `run_callbacks' lib/action_dispatch/middleware/callbacks.rb:30:in `call' lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call' lib/action_dispatch/middleware/debug_exceptions.rb:31:in `call' lib/action_dispatch/middleware/show_exceptions.rb:32:in `call' test/abstract_unit.rb:110:in `call' /home/zzak/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rack-test-2.1.0/lib/rack/test.rb:360:in `process_request' /home/zzak/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/rack-test-2.1.0/lib/rack/test.rb:153:in `request' lib/action_dispatch/testing/integration.rb:297:in `process' lib/action_dispatch/testing/integration.rb:19:in `get' lib/action_dispatch/testing/integration.rb:388:in `get' test/dispatch/request/session_test.rb:224:in `test_session_follows_rack_api_contract_1' ``` Co-authored-by:
viralpraxis <iaroslav2k@gmail.com> Co-authored-by:
zzak <zzakscott@gmail.com> Co-authored-by:
Hartley McGuire <skipkayhil@gmail.com>
-
- Nov 17, 2024
-
-
Eileen M. Uchitelle authored
Remove `# typed: true` sigil
-
Ryuta Kamizono authored
This is the only place in our codebase where sigil was added (#53065), so it was probably added accidentally.
-
Jean Boussier authored
Fix multibyte character tokenization bug in ERB::Util
-
fatkodima authored
[Docs] Remove extra parenthesis [ci skip]
-
Martin Emde authored
-
Yana Prystopchuk authored
-
- Nov 16, 2024
-
-
Petrik de Heus authored
Document options for `render` in API [ci skip]
-
Jean Boussier authored
Preserve timezone and locale in ActiveJob exception handlers
-
fatkodima authored
-
Jean Boussier authored
Allow to reset cache counters for multiple records
-
Jean Boussier authored
Define column methods on the ColumnMethods module
-
Cody Cutrer authored
The way they were being defined inside the `included` hook meant they ended up being defined directly on TableDefinition, contrary to the documentation: https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/PostgreSQL/ColumnMethods.html I left `define_column_methods` as a class method that gets extended onto TableDefinition, since there's at least one gem that relies on being able to call it there to define their own column types
-
fatkodima authored
-
Jean Boussier authored
Remove test_unit plugin_generator
-
Hartley McGuire authored
While looking for templates using the `.rb` extension instead of `.rb.tt`, my search ended up finding this `test_helper.rb` file. ``` $ fd | rg "/templates/.*\.rb$" ./actioncable/lib/rails/generators/channel/templates/application_cable/channel.rb ./actioncable/lib/rails/generators/channel/templates/application_cable/connection.rb ./railties/lib/rails/generators/test_unit/plugin/templates/test_helper.rb ``` Instead of correcting the extension, I opted to remove it because the `test_unit:plugin` generator appears to be unused. Co-Authored-By:
Jean Boussier <jean.boussier@gmail.com>
-
Jean Boussier authored
Add info on how to use the buffers option in Postgres [ci skip]
-
Jean Boussier authored
Don't parse response content type if value comes from Mime
-
Petrik authored
Anytime `ActionDispatch::HTTP::Reponse#content_type=` is called, the `content_type` argument is parsed using the CONTENT_TYPE_PARSER regexp. If the `content_type` argument comes from `Mime`, there is no need to parse it using the regexp as we already know the result. ```ruby require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "rails" gem "benchmark-ips" end require "action_controller/railtie" require 'benchmark/ips' Benchmark.ips do |x| x.config(:time => 5, :warmup => 2) response = ActionDispatch::Response.new x.report("main") do response.content_type = Mime[:html].to_s end class BranchResponse < ActionDispatch::Response def content_type=(content_type) case content_type when NilClass return when Symbol new_header_info = ContentTypeHeader.new(Mime[content_type]) else new_header_info = parse_content_type(content_type.to_s) end prev_header_info = parsed_content_type_header charset = new_header_info.charset || prev_header_info.charset charset ||= self.class.default_charset unless prev_header_info.mime_type set_content_type new_header_info.mime_type, charset end end response = BranchResponse.new x.report("branch") do response.content_type = :html end x.compare! end ``` ``` Warming up -------------------------------------- main 38.666k i/100ms branch 52.235k i/100ms Calculating ------------------------------------- main 393.529k (± 3.3%) i/s (2.54 μs/i) - 1.972M in 5.016529s branch 494.789k (± 2.2%) i/s (2.02 μs/i) - 2.507M in 5.069774s Comparison: branch: 494788.6 i/s main: 393529.2 i/s - 1.26x slower ``` This improves the plain json call in the TechEmpower benchmark by reducing the time spent in `#assign_default_content_type_and_charset!` from 16% to 6.5%. It probably improves other calls as well.
-
Jean Boussier authored
Add affected_rows to sql.active_record
-
Hartley McGuire authored
The [recently added][1] `row_count` value is very useful for identifying cases where a query would return a large result set as large results can end up using a lot of memory or even be blocked by databases like Vitess. However, somewhere that `row_count` falls short is for queries that do not necessarily return their results back to the client. These queries that affect too many rows can lead to their own set of problems, such as overwhelming replication and causing replication lag. This commit adds the number of `affected_rows` to the `sql.active_record` Notification so that these kinds of queries can be identified as well. [1]: e9a2288c
-