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

exclude fields from getting indexed by datastore #16

Merged
merged 4 commits into from
Sep 11, 2019

Conversation

Sheshagiri
Copy link
Owner

@Sheshagiri Sheshagiri commented Sep 10, 2019

This release adds support for excluding the fields from being indexed by google cloud datastore using a custom extension
in proto files.
Please note that exclude only works with one extension

@codecov
Copy link

codecov bot commented Sep 10, 2019

Codecov Report

Merging #16 into master will decrease coverage by 4.16%.
The diff coverage is 79.16%.

@@            Coverage Diff             @@
##           master      #16      +/-   ##
==========================================
- Coverage   97.35%   93.19%   -4.17%     
==========================================
  Files           1        1              
  Lines         227      235       +8     
==========================================
- Hits          221      219       -2     
- Misses          3       11       +8     
- Partials        3        5       +2
Impacted Files Coverage Δ
datastore-translator/translator.go 93.19% <79.16%> (-4.17%) ⬇️

@Sheshagiri Sheshagiri marked this pull request as ready for review September 10, 2019 12:44
var excludeIndex string
// use the Extension name is passed else derive it dynamically
if excludeFromIndexName != nil && len(excludeFromIndexName) > 0 {
excludeFromIndexExt = fmt.Sprintf("[%s]:true ", excludeFromIndexName[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting way to find an extension, works for me :)

Copy link
Contributor

@Kami Kami left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@Sheshagiri Sheshagiri merged commit 9f60b66 into master Sep 11, 2019
@Sheshagiri Sheshagiri deleted the support-exclude-indexing branch September 11, 2019 12:48
@@ -18,21 +19,48 @@ import (
)

// ProtoMessageToDatastoreEntity will generate an Entity Protobuf that datastore understands
func ProtoMessageToDatastoreEntity(src proto.Message, snakeCase bool, excludeFromIndex []string) (entity datastore.Entity, err error) {
func ProtoMessageToDatastoreEntity(src proto.Message, snakeCase bool, excludeFromIndexName ...string) (entity datastore.Entity, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I kinda missed that earlier, for explicitness sake, it wouldn't hurt if this argument is called excludeFromIndexOptionName or similar to make it clear that this expects extension option name.

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.

2 participants