-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Rails 8 #2483
Support Rails 8 #2483
Conversation
@@ -74,7 +74,8 @@ def fragment_cache(cached_hash, non_cached_hash) | |||
# see https://github.com/rails-api/active_model_serializers/pull/965 | |||
# When <tt>options</tt> is +nil+, sets it to +{}+ | |||
def serialization_options(options) | |||
options ||= {} # rubocop:disable Lint/UselessAssignment | |||
options ||= {} | |||
options.frozen? ? options.dup : options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious if the cost of checking for freezing here is worth it vs. always duplicating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran a synthetic benchmark, and both options show almost identical performance:
user system total real
Always dup: 0.458805 0.015979 0.474784 ( 0.475676)
Cond. dup (frozen): 0.460826 0.014778 0.475604 ( 0.476971)
Cond. dup (not frozen): 0.459270 0.010303 0.469573 ( 0.471081)
For reference, here is the script I used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to isolate this to the minimum change to get CI running on Rails 8 with the minimum runtime (vs. load time) differences. I've merged #2482
You up for focusing this PR on CI and getting it passing? It looks good
@bf4 Thanks for your reply. The CI is already passing: https://github.com/pulkit110/active_model_serializers/actions/runs/11772425914 and there are no runtime differences: Please let me know if you need any changes from my side to get this ready for merge. |
4f31ebd
to
da08a2c
Compare
FYI I have rebased my branch on 0-10-stable and the CI is passing: https://github.com/pulkit110/active_model_serializers/actions/runs/11866564182 |
Looks like this needs workflow approval after rebase? |
da08a2c
to
f33e76c
Compare
I noticed that the workflow was failing, so I pushed a fix in f33e76c The workflow requires approval again. |
f33e76c
to
b31d91c
Compare
Looks good to me. Let's merge this. |
Thanks for your work. Released 0.10.15 |
Purpose
Support Rails 8
Changes
There are two main changes:
dup
it if it's frozen.ActiveSupport::Deprecation.silence
is replaced byRails.deprecator.silence
This PR also adds Rails 7.2 and 8.0 to the test matrix.
Caveats
No caveats
Related GitHub issues
No related issues
Additional helpful information
This is my first contribution, so please let me know if something is missing and I'll try to answer it.