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 the keytransform datastore's query implementation #127

Merged
merged 7 commits into from
Apr 19, 2019
Merged

Conversation

Stebalien
Copy link
Member

@Stebalien Stebalien commented Apr 9, 2019

The namespace Datastore shouldn't have to touch the mess with the query. It was also only partially implementing the query logic, passing through filters, etc. without applying the key transform.

Also adds some tests.

@ghost ghost assigned Stebalien Apr 9, 2019
@ghost ghost added the status/in-progress In progress label Apr 9, 2019
@Stebalien Stebalien force-pushed the fix/ktds branch 2 times, most recently from 05e6f03 to cd09572 Compare April 18, 2019 02:27
Motivation: I want to be able to use the concrete type from a different package
but I can't.

This:

1. Exports the concrete datastore type and avoids returning private types from
   public functions.
2. Removes the mostly useless ktds interface. Unfortunately, it collides with
   the idiomatic name for the datastore itself.

This could break something referencing the `ktds.Datastore` type but nothing is
doing that.
The namespace Datastore shouldn't have to touch the mess with the query.

Note: this _also_ correctly applies ordering, filters, etc. to the transformed
keys (in both the namespaced and the key transform datastores).
Copy link
Member

@magik6k magik6k left a comment

Choose a reason for hiding this comment

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

Other than that 1 question LGTM

case dsq.OrderByKey, *dsq.OrderByKey,
dsq.OrderByKeyDescending, *dsq.OrderByKeyDescending:
if orderPreserving {
child.Orders = child.Orders[:i+1]
Copy link
Member

Choose a reason for hiding this comment

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

I feel like I'm missing something here. Why drop other orders here?

Copy link
Member Author

Choose a reason for hiding this comment

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

We sort hierarchically. That is, when comparing two entries, we compare with the first "order", then the second order if equal, then the third order if still equal, etc. Given that keys are unique, "order by key" will never return "equal" so there's no point in applying further orders.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a comment and improved the test coverage more to get codecov to stop complaining.

@Stebalien Stebalien merged commit 9db638c into master Apr 19, 2019
@Stebalien Stebalien deleted the fix/ktds branch April 19, 2019 16:46
@ghost ghost removed the status/in-progress In progress label Apr 19, 2019
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