Merged
Conversation
The method was already using `request.body` directly; the parameter was never read.
Change `adapter_sqlite?` and `adapter_sqlserver?` from `||=` memoization to `defined?`-based memoization. The `||=` pattern doesn't memoize false, causing `active_storage_db_adapter_name` (which acquires a DB connection) to be re-evaluated on every call for non-SQLite/non-SQLServer adapters.
Extract the duplicated `respond_to?(:name) ? name : "db"`` expression into a `service_name_for_token`` private method, used in both `url_for_direct_upload`` and `generate_url`.
Wrapped the search filename in `ActiveRecord::Base.sanitize_sql_like()` so that `%` and `_` characters in user input are treated as literals rather than SQL LIKE wildcards.
Change `compose` to use `find_by` + explicit `raise ActiveStorage::FileNotFoundError` instead of `find_by!` (which raises `ActiveRecord::RecordNotFound`). This makes the error type consistent with every other method in the service.
Added missing `else example.run`` to the `around` block. Without this, tests in the "with a new target entity" context were silently skipped on Rails < 7.1 (where `touch_attachment_records` doesn't exist).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Internal improvements:
service_name_for_tokenabstraction in db_service.rbbodykeyword in files_controller.rbsanitize_sql_likein search taskFileNotFoundErrorin db_service_rails70.rb