Skip to content
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

[firestore-emulator: datastore-mode] Kind query return empty list #6903

Open
artoale opened this issue Mar 22, 2024 · 1 comment
Open

[firestore-emulator: datastore-mode] Kind query return empty list #6903

artoale opened this issue Mar 22, 2024 · 1 comment

Comments

@artoale
Copy link

artoale commented Mar 22, 2024

General description

dastore-mode does not support Kind Queries

This is absolutely essential to support using the emulator in a testing environment, since you need to be able to list all the kinds in the db to be able to (potentially selectively) delete all of them.

[REQUIRED] Environment info

firebase-tools: Using the gcloud cli version 468.0.0, firestore emulator: 1.19.3

Platform: macOS (intel), python client library

[REQUIRED] Test case

import os

from google.cloud import datastore
from google.cloud.datastore.query import PropertyFilter


def main():
    PORT = 10901
    os.environ["DATASTORE_EMULATOR_HOST"] = "127.0.0.1:%s" % PORT
    os.environ["DATASTORE_PROJECT_ID"] = "test"

    def get_new_client():
        return datastore.Client(
            project="test",
            namespace=None,
            _http=None,
        )

    client = get_new_client()

    kind = "a_kind"
    key = client.key(kind)
    entity = datastore.Entity(key=key)
    entity.update({"foo": "bar"})

    client.put(entity)

    all_kinds = list(client.query(kind="__kind__").fetch())
    print(all_kinds)
    assert kind in [x.key.name for x in all_kinds]


if __name__ == "__main__":
    main()

[REQUIRED] Steps to reproduce

  1. Start the emulator with gcloud emulators firestore start --host-port=127.0.0.1:10901 --database-mode=datastore-mode
  2. Install the python deps: pip install google-cloud-datastore==2.19.0
  3. Run the above python script

[REQUIRED] Expected behavior

Completes, printing the following output:

[<Entity('__kind__', 'a_kind') {}>]

[REQUIRED] Actual behavior

Output is

[]

and the assertion fails.

Additional information

Note: the same test works as expected with both a real datastore instance or the old legacy datastore emulator

@harshyyy21
Copy link
Contributor

Thanks for bringing this up Alessandro! This is unsupported in the current implementation of the new emulator. Will try to get it out as soon as possible and will update this thread when done. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants