-
Notifications
You must be signed in to change notification settings - Fork 65
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
Conversation
05e6f03
to
cd09572
Compare
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).
There was a problem hiding this 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] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.