Bugfix: Allow chaining with same attribute#271
Closed
gastronleroux wants to merge 1 commit intoactive-hash:masterfrom
Closed
Bugfix: Allow chaining with same attribute#271gastronleroux wants to merge 1 commit intoactive-hash:masterfrom
gastronleroux wants to merge 1 commit intoactive-hash:masterfrom
Conversation
d1b4b9b to
6e89753
Compare
kbrock
reviewed
Jan 17, 2023
kbrock
reviewed
Jan 17, 2023
| expect(chained_where_relation.map(&:id)).to eq([1]) | ||
| end | ||
|
|
||
| it "is chainable with same attribute" do |
kbrock
reviewed
Jan 18, 2023
lib/active_hash/relation.rb
Outdated
|
|
||
| self.records_dirty = true unless query_hash.nil? || query_hash.keys.empty? | ||
| self.query_hash.merge!(query_hash || {}) | ||
| self.query_list.concat(query_hash&.to_a || []) |
Collaborator
There was a problem hiding this comment.
so this is the main bug that this PR is addressing.
The original merge drops the existing keys, the new concat will keep the duplicate keys.
kbrock
reviewed
Jan 18, 2023
Collaborator
kbrock
left a comment
There was a problem hiding this comment.
I admit that I am sad to see the hash go away and see the code move towards an array.
It only really shows up as a disadvantage when we are doing a search by id. So I guess it is no big deal.
I just have the one request for update which is minor
Please tweak that and squash your commits and we can merge this.
Remove redundant `|| []` Apply suggestions
eb527ed to
b068b64
Compare
Collaborator
|
Thank you for helping us with this solution. Going with #268 instead |
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.
Expected behavior:
Current behavior: