Skip to content

Internal improvements#80

Merged
blocknotes merged 6 commits intomainfrom
internal-improvements
Mar 15, 2026
Merged

Internal improvements#80
blocknotes merged 6 commits intomainfrom
internal-improvements

Conversation

@blocknotes
Copy link
Copy Markdown
Owner

@blocknotes blocknotes commented Mar 15, 2026

Internal improvements:

  • update adapter methods memoization in db_service.rb
  • service_name_for_token abstraction in db_service.rb
  • remove unused body keyword in files_controller.rb
  • use sanitize_sql_like in search task
  • raise explicitly FileNotFoundError in db_service_rails70.rb
  • small fix in attachments spec

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).
@blocknotes blocknotes self-assigned this Mar 15, 2026
@blocknotes blocknotes marked this pull request as ready for review March 15, 2026 11:30
@blocknotes blocknotes merged commit 0144783 into main Mar 15, 2026
30 checks passed
@blocknotes blocknotes deleted the internal-improvements branch March 15, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant