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

excludeFromIndexes: fix for entity elements inside arrays #101

Merged
merged 11 commits into from
Jun 11, 2018
Merged

excludeFromIndexes: fix for entity elements inside arrays #101

merged 11 commits into from
Jun 11, 2018

Conversation

trollkotze
Copy link
Contributor

@trollkotze trollkotze commented Jun 8, 2018

Fixes #93
Fixes #100

  • Tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@codecov
Copy link

codecov bot commented Jun 8, 2018

Codecov Report

Merging #101 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #101   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           5      5           
  Lines         645    646    +1     
=====================================
+ Hits          645    646    +1
Impacted Files Coverage Δ
src/entity.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 445304c...6bc2b90. Read the comment docs.

@googlebot
Copy link

CLAs look good, thanks!

@@ -591,7 +591,17 @@ describe('entity', function() {
});

it('should respect excludeFromIndexes', function() {
var value = 'Stephen';
var value1 = 'Stephen';

This comment was marked as spam.

This comment was marked as spam.

@alexander-fenster
Copy link
Contributor

@trollkotze Welcome, and thanks for your contribution!

@stephenplusplus that's your code I guess, can you please take a look?

@trollkotze
Copy link
Contributor Author

I have now also added a simple fix for issue #93, with the example provided in that issue as a test.
This allows now something like:

entity = {
  key: key,
  excludeFromIndexes: ['arr[].a[].b'],
  data: {
    nestedArrayVariants: [
      {
        a: [{b:'something'},{c:'else'}],
      },{
        a: null,
      },{
        a: ['whatever'],
      }
    ],
  },
};

Previously, entityToEntityProto would have thrown a type error when encountering arr[i].a == null (or any other primitive value) while trying to exclude arr[].a[].b from indexes, thus disallowing detailed exclusion below nested properties that might sometimes be arrays and sometimes something else.
The fix is one simple property existence check that will rarely be traversed.

@JustinBeckwith
Copy link
Contributor

@stephenplusplus @callmehiphop can someone take a look?

@stephenplusplus
Copy link
Contributor

Awesome, thanks @trollkotze!

@stephenplusplus stephenplusplus merged commit 7eb5e20 into googleapis:master Jun 11, 2018
@evgenius
Copy link
Contributor

Hi guys, is there any chance this fix is released soon?
I faced the same issue and even started working on a patch but then realised it's already here but just not released yet.

@stephenplusplus stephenplusplus mentioned this pull request Jun 21, 2018
stephenplusplus added a commit that referenced this pull request Jun 21, 2018
## Fixes

- (#101): excludeFromIndexes behavior fix for entities inside arrays. (Thanks, @trollkotze!)
- Updated dependencies.
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.

None yet

6 participants