File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -759,7 +759,7 @@ def to_legacy_urlsafe(self, location_prefix):
759
759
"""
760
760
return google .cloud .datastore .Key (
761
761
self ._key .kind ,
762
- self ._key .id ,
762
+ self ._key .id or self . _key . name ,
763
763
namespace = self ._key .namespace ,
764
764
project = self ._key .project ,
765
765
).to_legacy_urlsafe (location_prefix = location_prefix )
Original file line number Diff line number Diff line change @@ -576,6 +576,15 @@ def test_to_legacy_urlsafe():
576
576
== b"agNzfmZyBwsSAWQYeww"
577
577
)
578
578
579
+ @staticmethod
580
+ @pytest .mark .usefixtures ("in_context" )
581
+ def test_to_legacy_urlsafe_name ():
582
+ key = key_module .Key ("d" , "x" , app = "f" )
583
+ assert (
584
+ key .to_legacy_urlsafe (location_prefix = "s~" )
585
+ == b"agNzfmZyCAsSAWQiAXgM"
586
+ )
587
+
579
588
@staticmethod
580
589
@pytest .mark .usefixtures ("in_context" )
581
590
@mock .patch ("google.cloud.ndb._datastore_api" )
You can’t perform that action at this time.
0 commit comments