fix: location prefix support - #327
Conversation
…fix in a urlsafe key
|
When I looked at #264, the reason I marked it "blocked" was because I couldn't find a way to get the prefix. I thought maybe you had found something I hadn't, but when I look at your solution, it's something I had already tried. I just don't get a prefix when I do this: The problem I found is that the Datastore GUI was giving us ursafe keys with the prefix, but we had no way to get the prefix on the client side. I still don't see a way forward on that. Am I missing something? |
|
Thanks Chris, We are actually trying to preserve original ndb functionality - so when we serialize a key to urlsafe we would like to have the I tried not to change the interfaces as much as possible. However, there are certainly other ways to do this. For example, add location_prefix as a KWARG to Commit 1 example:from google.cloud import ndb
client = ndb.Client(project='s~project-id')
project = ndb_client.client.projectCommit 2 example:from google.cloud import ndb
client = ndb.Client(project='project-id')
key = ndb.Key('SomeKind', 1234)
urlsafe_key = key.legacy_urlsafe(location_prefix='s~') |
|
Ok, so you're just presuming that the programmer already knows the prefix. That can probably work as a compromise. Let's see if @andrewsg gets anything out of the Datastore team about this. |
|
Integrated in #348 |
This PR has two ideas implemented, only one may need to be pulled.
Commit 1 - optionally include location prefix when creating
ndb.KeyinstancesCommit 2 - use a secondary method
legacy_urlsafeto include location prefix in urlsafe key.Thanks for the support and updates. We look forward to communicating the best way to include location prefix.
NOTE: I noticed that adding location prefix caused tests that expect the location prefix to be stripped away to fail. We can help resolve these tests by anticipating the prefix to be kept.
Fixes: #264