| Index: service/datastore/key.go
|
| diff --git a/service/datastore/key.go b/service/datastore/key.go
|
| index 2071bfb7b2ad01ceed9c42592d5d6ba01fb6b053..85dd1c4508b95d05ae9d44f4a8a70feb6a927eb6 100644
|
| --- a/service/datastore/key.go
|
| +++ b/service/datastore/key.go
|
| @@ -414,14 +414,27 @@ func (k *Key) GQL() string {
|
| }
|
|
|
| // Equal returns true iff the two keys represent identical key values.
|
| -func (k *Key) Equal(other *Key) (ret bool) {
|
| +func (k *Key) Equal(other *Key) bool {
|
| + return k.SameKind(other) && (k.LastTok() == other.LastTok())
|
| +}
|
| +
|
| +// SameKind asserts that other refers to the same entity as k. This checks the
|
| +// full lineage of the key.
|
| +func (k *Key) SameKind(other *Key) (ret bool) {
|
| ret = (k.appID == other.appID &&
|
| k.namespace == other.namespace &&
|
| len(k.toks) == len(other.toks))
|
| if ret {
|
| for i, t := range k.toks {
|
| - if ret = t == other.toks[i]; !ret {
|
| - return
|
| + if i == len(k.toks)-1 {
|
| + // Last token: check only Kind.
|
| + if ret = (t.Kind == other.toks[i].Kind); !ret {
|
| + return
|
| + }
|
| + } else {
|
| + if ret = t == other.toks[i]; !ret {
|
| + return
|
| + }
|
| }
|
| }
|
| }
|
|
|