| Index: service/datastore/key.go
|
| diff --git a/service/datastore/key.go b/service/datastore/key.go
|
| index 3bf02e861e3f99118fab2258070106b04ca45091..b2b9e45f37da085b33f76f68f0f7d9ea5b791dc5 100644
|
| --- a/service/datastore/key.go
|
| +++ b/service/datastore/key.go
|
| @@ -359,6 +359,22 @@ func (k *Key) Less(other *Key) bool {
|
| return len(k.toks) < len(other.toks)
|
| }
|
|
|
| +// HasAncestor returns true iff other is an ancestor of k (or if other == k).
|
| +func (k *Key) HasAncestor(other *Key) bool {
|
| + if k.appID != other.appID || k.namespace != other.namespace {
|
| + return false
|
| + }
|
| + if len(k.toks) < len(other.toks) {
|
| + return false
|
| + }
|
| + for i, tok := range other.toks {
|
| + if tok != k.toks[i] {
|
| + return false
|
| + }
|
| + }
|
| + return true
|
| +}
|
| +
|
| // GQL returns a correctly formatted Cloud Datastore GQL key literal.
|
| //
|
| // The flavor of GQL that this emits is defined here:
|
|
|