Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Unified Diff: impl/prod/datastore_key.go

Issue 1292913002: Split off serialization and key functions to their own packages. (Closed) Base URL: https://github.com/luci/gae.git@make_queries_better
Patch Set: rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « impl/memory/testing_utils_test.go ('k') | service/datastore/checkfilter.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/prod/datastore_key.go
diff --git a/impl/prod/datastore_key.go b/impl/prod/datastore_key.go
index fde1c970f405b0dbb3e5eba12576089aceb55c5a..e17286f3f769d84815fef6541a54cd7ddd250f3b 100644
--- a/impl/prod/datastore_key.go
+++ b/impl/prod/datastore_key.go
@@ -6,6 +6,7 @@ package prod
import (
ds "github.com/luci/gae/service/datastore"
+ "github.com/luci/gae/service/datastore/dskey"
"google.golang.org/appengine/datastore"
)
@@ -15,7 +16,14 @@ type dsKeyImpl struct {
var _ ds.Key = dsKeyImpl{}
-func (k dsKeyImpl) Parent() ds.Key { return dsR2F(k.Key.Parent()) }
+func (k dsKeyImpl) Parent() ds.Key { return dsR2F(k.Key.Parent()) }
+func (k dsKeyImpl) Incomplete() bool { return k.Key.Incomplete() }
+func (k dsKeyImpl) Valid(allowSpecial bool, aid, ns string) bool {
+ return dskey.Valid(k, allowSpecial, aid, ns)
+}
+func (k dsKeyImpl) PartialValid(aid, ns string) bool {
+ return dskey.PartialValid(k, aid, ns)
+}
// dsR2F (DS real-to-fake) converts an SDK Key to a ds.Key
func dsR2F(k *datastore.Key) ds.Key {
@@ -29,7 +37,7 @@ func dsF2R(k ds.Key) *datastore.Key {
}
// we should always hit the fast case above, but just in case, safely round
// trip through the proto encoding.
- rkey, err := datastore.DecodeKey(ds.KeyEncode(k))
+ rkey, err := datastore.DecodeKey(dskey.Encode(k))
if err != nil {
// should never happen in a good program, but it's not ignorable, and
// passing an error back makes this function too cumbersome (and it causes
« no previous file with comments | « impl/memory/testing_utils_test.go ('k') | service/datastore/checkfilter.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698