GoogleCloudPlatform / spring-cloud-gcp

New home for Spring Cloud GCP development starting with version 2.0.
Apache License 2.0
410 stars 304 forks source link

Support --use-firestore-in-datastore-mode in the datastore emulator. #1406

Open ablx opened 1 year ago

ablx commented 1 year ago

At the moment, the datastore emulator is not able to act as the "real" Firestore in Datastore mode. To be specific, transactions do only allow ancestor queries. The emulator itself is capable of behaving like Firestore in Datastore mode, using the argument --use-firestore-in-datastore-mode - but one cannot set this in Spring.

Datastore Docs: https://cloud.google.com/datastore/docs/firestore-or-datastore#in_datastore_mode

meltsufin commented 1 year ago

We'd be happy to accept a contribution for this! Thanks!

ablx commented 1 year ago

Hey, I took a look into this. Unfortunally, this requires a change in com.google.cloud.datastore.testing.LocalDatastoreHelper (to hand over the parameter to the emulator) which is not part of the Spring Integration - and I was not able to find that class here on GitHub, so it seems it is not open source.

ablx commented 1 year ago

For everyone with the same problem: One can use Testcontainers as a workaround. See this gist: https://gist.github.com/ablx/44a47523235bf2f3a4b63a4088d7945b

meltsufin commented 1 year ago

For the record, LocalDatastoreHelper is open source - https://github.com/googleapis/java-datastore/blob/main/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java. Thanks for sharing the testcontainers option!

ablx commented 1 year ago

Great, thanks for the link. I'll implement the feature in the near future.