-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Prevent creation of unnecessary fieldset(mirror and revised) #2449
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
Closed
liijunwei
wants to merge
244
commits into
rails-api:master
from
liijunwei:prevent_creation_of_unnecessary_fieldset
Closed
Prevent creation of unnecessary fieldset(mirror and revised) #2449
liijunwei
wants to merge
244
commits into
rails-api:master
from
liijunwei:prevent_creation_of_unnecessary_fieldset
Conversation
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
Fix typos and capitalization in Relationship Links docs [ci skip]
Run tests by Ruby 2.2.6 and 2.3.3
Promote important architecture description that answers a lot of questions we get Conflicts: docs/ARCHITECTURE.md
Fix typos [ci skip]
Link to 0.10.3 tag instead of `master` branch
Test was failing due to change in JSON exception message when parsing empty string
* delete KeyTransform, use CaseTransform * added changelog Conflicts: CHANGELOG.md
Update jsonapi runtime dependency to 0.1.1.beta6
Prepare release of 0.10.4
Bump to v0.10.4 [ci skip] Conflicts: CHANGELOG.md
Fix AMS warnings
Silence Grape warnings
Fix mt6 assert_nil warnings
* Updated isolated tests to assert correct behavior. * Added check to get unsafe params if rails version is great than 5
…enderer_tests_a_bit Cleanup assertions in isolated jsonapi renderer tests a bit
Add Model#attributes helper; make test attributes explicit
Fix model attribute accessors
Fix relationship links doc Conflicts: CHANGELOG.md
Fix small typo in README.md
If the `id` attribute for a class isn't taken directly from the object when serializing it, it may be desirible for other classes that serialize a relationship with that class to overwrite the relationship IDs they serialize. For example, suppose we have: ```(ruby) class Repo < Model attributes :id, :github_id, :name associations :configs end class Config < Model attributes :id belongs_to :repo end class RepoSerializer < ActiveModel::Serializer attributes :id, :name has_many :update_configs def id object.github_id end end class ConfigSerializer < ActiveModel::Serializer attributes :id belongs_to :repo end ``` In the above example, serializing a list of `Repo`s will give the `github_id` for each one, but serializing a `Config` will give the `id` for its parent repo. Ideally AMS would inspect the `RepoSerializer` when serializing the `Config`, and realise it can't just output the foreign key. Unfortunately, getting the serialization class for the child repo currently requires loading the record (via evaluating `lazy_assocation`), and loses the performance benefit of the existing `belongs_to?` path. Instead, I've opted to use `read_attribute_for_serialization` instead of `object.send` to fetch the serialized foreign key. This allows the serialized relationship ID to be overwritten using ```(ruby) class ConfigSerializer < ActiveModel::Serializer ... def repo_id object.repo.github_id end end ```
…ge is greater than total_pages adding tests fixing rubocop violation
default activity types: [opened, synchronize, reopened] doc: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#pull_request
Trigger github actions workflow on pull request
…izers into 0-10-stable
Handle edge case where requested current_page > total_pages in JSONAPI
[docs] disable logger via /dev/null instead of AS::N.unsubscribe
…nnot_infer_root_key_error_option Add raise_cannot_infer_root_key_error to config
Relax gem requirement for Rails 7.0 prerelease
Relax gem requirement to allow Rails 7
The `Module#method_defined?` works for an instance method. But `with_unbundled_env` defines as a class method. Therefore, the current check doesn't work as expected. ```ruby require "bundler" puts Bundler.method_defined?(:with_unbundled_env) # => false puts Bundler.respond_to?(:with_unbundled_env) # => true ``` This fixes the following message that shows when running a test. ``` [DEPRECATED] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env` (called at /home/y-yagi/src/github.com/rails-api/active_model_serializers/Rakefile:68) ```
…method Fix checking of method defined or not
Remove TravisCI settings
…i#2370) * refactor: instance_options[:fieldset] must be nil as it's not listed in ADAPTER_OPTION_KEYS
wrong target branch, pls ignore |
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.
Purpose
Changes
fieldset
is not listed inlib/active_model_serializers/serializable_resource.rb@ADAPTER_OPTION_KEYS
, remove the||=
protection (simplification)ActiveModel::Serializer::Fieldset
instance whenfieldset
is empty (optimization)fieldset
falsy before using itCaveats
NA
Related GitHub issues
Additional helpful information