-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.project Commit 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.Key
instancesCommit 2 - use a secondary method
legacy_urlsafe
to 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