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

[BUGFIX release] fix regression with computed filter/map/sort #15855

Merged
merged 3 commits into from
Nov 28, 2017

Conversation

bekzod
Copy link
Contributor

@bekzod bekzod commented Nov 14, 2017

filter/map/sort would not expand items.@each.{prop1,prop2} therefore would not properly work

@bekzod
Copy link
Contributor Author

bekzod commented Nov 14, 2017

fixes #15843

Copy link
Member

@rwjblue rwjblue left a comment

Choose a reason for hiding this comment

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

This regression was introduced in #15550 which changed both the reduceMacro, multiArrayMacro,and arrayMacro ( the one fixed in this PR) invocations to directly pass dependentKeys in options (and therefore avoiding expand properties).

Can you add a test for the same regression that uses multiArrayMacro (Ember.computed.uniq for example) and reduceMacro (Ember.computed.sum for example) using brace expansion, and update those implementations also?

}, { dependentKeys: [ dependentKey ], readOnly: true });
}, { readOnly: true });

cp.property(dependentKey);
Copy link
Member

Choose a reason for hiding this comment

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

👍 the fix is good, but I wanted to comment here to explain why this is different.

The ComputedProperty constructor does not run the provided dependent keys through expandProperties (perhaps it should, but that is another issue altogether). So moving this out from the constructor options into cp.property forces it to run expandProperties.

Copy link
Contributor Author

@bekzod bekzod Nov 14, 2017

Choose a reason for hiding this comment

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

it is intentional that constructor argument does not run through expandProperties to avoid extra work (so it expects expanded properties already) because I made dependent keys passable through constructor :P actually

@bekzod
Copy link
Contributor Author

bekzod commented Nov 14, 2017

I think rest of computed properties are not affected by regression, because computed properties that use reduceMacro and multiArrayMacro just expect array property name, I can add assertion for passing expandable properties to computed properties that use reduceMacro/multiArrayMacro (for sum, max, min) if it is necessary

@rwjblue
Copy link
Member

rwjblue commented Nov 14, 2017

I can add assertion for passing expandable properties to computed properties that use reduceMacro/multiArrayMacro (for sum, max, min) if it is necessary

Seems good to me. Can you add that assertion in a separate commit (as a [BUGFIX beta] instead of release)?

function reduceMacro(dependentKey, callback, initialValue) {
function reduceMacro(dependentKey, callback, initialValue, name) {
assert(
`Dependent key passed to Ember.computed.${name}() shouldn't contain brace expading pattern.`,
Copy link
Member

Choose a reason for hiding this comment

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

typo s/expading/expanding/

function multiArrayMacro(_dependentKeys, callback) {
function multiArrayMacro(_dependentKeys, callback, name) {
assert(
`Dependents keys passed to Ember.computed.${name}() shouldn't contain brace expading pattern.`,
Copy link
Member

Choose a reason for hiding this comment

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

same as above

@@ -17,8 +17,12 @@ import compare from '../compare';
import { isArray } from '../utils';
import { A as emberA } from '../system/native_array';

function reduceMacro(dependentKey, callback, initialValue, name) {
assert(
`Dependent key passed to Ember.computed.${name}() shouldn't contain brace expading pattern.`,
Copy link
Member

Choose a reason for hiding this comment

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

s/expading/expanding/

function multiArrayMacro(_dependentKeys, callback) {
function multiArrayMacro(_dependentKeys, callback, name) {
assert(
`Dependent keys passed to Ember.computed.${name}() shouldn't contain brace expading pattern.`,
Copy link
Member

Choose a reason for hiding this comment

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

s/exading/expanding/

@bekzod bekzod force-pushed the filter-computed-expand branch 4 times, most recently from 837adae to 2b557dc Compare November 14, 2017 20:21
@urbany
Copy link

urbany commented Nov 21, 2017

Hi, will this make it to 2.17?

@rwjblue
Copy link
Member

rwjblue commented Nov 28, 2017

I believe so (and ultimately backported to 2.16 also)...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants