Friday, June 7, 2024

Global strict loading mode setting, route draw deferring and more

Posted by Wojtek

Hi, Wojtek here. Let’s explore this week’s changes in the Rails codebase.

Rails security releases
Rails Versions 6.1.7.8, 7.0.8.4, 7.1.3.4, and 7.2.0.beta2 have been released with a security issue fix.

The CFP for RubyConf is open
Submissions on all Ruby Web Frameworks, including Rails, will be considered, so get your Rails related submissions ready!

Allow to set strict_loading_mode globally
Sets the mode via config.active_record.strict_loading_mode in which strict loading is reported. Defaults to :all. It can be changed to :n_plus_one_only to only report when loading associations that will lead to an “N + 1 query”. This can be set globally or within a model.

Defer route drawing to the first request, or when url_helpers called
Executes the first routes reload in middleware, or when a route set’s url_helpers receives a route call / asked if it responds to a route. Previously, this was executed unconditionally on boot, which slowed down boot time unnecessarily for larger apps with lots of routes.

Add an explicit dependency on the logger gem
It is a bundled gem candidate for Ruby 3.5, thus it would start to warn without it.

Re-roll deprecation of to_time_preserves_timezone
The previous deprecation hadn’t been warning for all users, so proceeding to removal could cause an un-warned change in behaviour.

Include the current transaction in sql.active_record event payloads
Use case is to allow tracing database activity including the ability to group queries by transaction, thanks to the recently added ActiveRecord::Transaction#uuid. Enhanced later with nil handling change

Fix IDs reader on preloaded associations for composite primary keys
Now calling an example association with composite primary keys author.books.ids works as expected.

You can view the whole list of changes here. We had 30 contributors to the Rails codebase this past week!

Until next time!

Subscribe to get these updates mailed to you.