Skip to content
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

fix: filterBy should compare values #8171

Merged
merged 1 commit into from Sep 8, 2022
Merged

fix: filterBy should compare values #8171

merged 1 commit into from Sep 8, 2022

Conversation

jrjohnson
Copy link
Sponsor Contributor

Description

FilterBy can be called with and without a second argument, when the second argument is used the filter should compare that value to the value in the record.

I slapped the test for this in a sort of random spot because I wasn't sure where it goes.

Type of PR

What kind of change is this?

  • refactor
  • internal bugfix
  • user-facing bugfix
  • new feature
  • deprecation
  • documentation
  • something else (please describe)
  • tests

@runspired runspired added 🎯 beta PR should be backported to beta 🎯 release PR should be backported to release 🎯 canary PR is targeting canary (default) 🏷️ bug This PR primarily fixes a reported issue labels Sep 8, 2022
return this.filter((value) => {
return Boolean(get(value, key));
return this.filter((record) => {
return Boolean(get(record, key));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦 you may want to check the other implementations to make sure I didn't make a similar mistake with them

Copy link
Sponsor Contributor Author

@jrjohnson jrjohnson Sep 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆 copy paste so useful, so easy to mess up. I eyeballed the rest and they looked good, decided not to write a bunch of soon to be deprecated tests though seemed like overkill.

@@ -97,6 +97,46 @@ module('unit/record-arrays/record-array - DS.RecordArray', function (hooks) {
assert.strictEqual(recordArray[3], undefined);
});

test('#filterBy', async function (assert) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll want to use deprecatedTest vs assert.expectDeprecation both so we know to clean it up later and because it will then get skipped when deprecations are removed and we run the tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a perfectly fine place for this test btw

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆒 thanks. Fixed.

FilterBy can be called with and without a second argument, when the
second argument is used the filter should compare that value to the
value in the record.
@jrjohnson jrjohnson marked this pull request as ready for review September 8, 2022 19:26
@jrjohnson jrjohnson merged commit 94cf39f into emberjs:master Sep 8, 2022
@jrjohnson jrjohnson deleted the filter-by-test branch September 8, 2022 23:39
@jrjohnson jrjohnson removed the 🎯 release PR should be backported to release label Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎯 beta PR should be backported to beta 🎯 canary PR is targeting canary (default) 🏷️ bug This PR primarily fixes a reported issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants