GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Datastore Query should work when no Client is passed · Issue #2465 · googleapis/google-cloud-python

Datastore Query should work when no Client is passed #2465

New issue
Copy link
New issue
Copy link
Closed
Closed
Datastore Query should work when no Client is passed#2465
Copy link
Assignees
vikkyrk
Labels
api: datastoreIssues related to the Datastore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Description

@vikkyrk
vikkyrk
opened on Sep 29, 2016
Issue body actions

We are trying to use gcloud-python Datastore in Apache Beam python SDK to provide a Datastore connector. For our use case, the user will just provide a 'com.google.datastore.query.Query' and the connector will take care of reading data from Datastore. We do not want the user to deal with 'datastore.Client' directly. The way we plan to implement is something like this,

User Pseudo Code

project = 'myproject'
namespace = 'mynamespace'
query = Query(client=None, project, namespace )
query.add_filter(...)
DatastoreConnector.read(query, project, namespace)

SDK Connector Pseudo Code

def DatastoreConnector.read(query, project, namespace):
  client = datastore.Client(project, namespace)
  return query.fetch(client=client)

Note that we are passing the client to the query at fetch time. All this works fine when the namespace is not empty but when namespace is None, the code fails with an exception, AttributeError: 'NoneType' object has no attribute 'namespace'. This is because the Query tries to get the namespace from Client even though Client is empty. Specifically fails here and here

Could these checks be changed to,

if not namespace:
  self._namespace = namespace
elif not client:
  self._namespace = client.namespace

Or is there any workaround for us?

Activity

  1. dhermes
    added
    api: datastoreIssues related to the Datastore API.
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Sep 29, 2016
  2. dhermes commented on Sep 29, 2016

    @dhermes
    dhermes
    on Sep 29, 2016
    Contributor
    More actions

    @vikkyrk It's something we had never considered. I suppose it would be just fine. Rather than using the if statement it'd be easier to just use

    getattr(client, 'namespace', None)

    in place of client.namespace.

    Would you like to send a patch? (It'll need one or two new unit tests but not much else.)

  3. vikkyrk commented on Sep 29, 2016

    @vikkyrk
    vikkyrk
    on Sep 29, 2016
    Author
    More actions

    @dhermes PTAL, #2467

  4. vikkyrk
    closed this as completedon Dec 2, 2016
  5. JustinBeckwith
    assigned
    vikkyrk
    on Feb 1, 2021
  6. parthea
    added a commit that references this issue on Nov 24, 2025

    chore(main): release 1.28.2 (#2465)

    3c7c67a
  7. parthea
    added 2 commits that reference this issue on Apr 1, 2026

    docs: use direct API for image (#2465)

    79d47c3

    chore: librarian release pull request: 20260303T181914Z (#2489)

    72b1c96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @vikkyrk
    vikkyrk

Labels

api: datastoreIssues related to the Datastore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.