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

Support for Cloud Datastore in Dart without relying on dart:mirrors #89

Open
bwnyasse opened this issue May 19, 2023 · 2 comments
Open
Labels
package:gcloud type-enhancement A request for a change that isn't a bug

Comments

@bwnyasse
Copy link

Description:
I'm currently using the gcloud package in my Dart application to work with Cloud Datastore. However, I encountered an issue when trying to use the package with the Cloud Datastore due to the reliance on the dart:mirrors package. The dart compile command fails with the following error:

error: import of dart:mirrors is not supported in the current Dart runtime
Error: AOT compilation failed
Generating AOT snapshot failed!

I believe it would be beneficial to provide an alternative way to define Datastore models without relying on the dart:mirrors package. This would enable the use of Cloud Datastore in Dart applications without encountering the reflection-related limitations imposed by the Dart runtime when calling dart compile command.

In the documentation, the usage of the @db.Kind() and @db.Property() annotations from the gcloud package is demonstrated. However, since Dart's AOT compilation does not support dart:mirrors, it would be helpful to have an alternative approach for defining Datastore models that doesn't rely on reflection.

My use case:

I am trying to use the package to build a faas with functions-framework-dart . When building the tiny docker image, the dart compile command fails if I use Datastore library.

@nagakuta
Copy link

nagakuta commented Sep 2, 2023

I'm one of those who would like to see this issue resolved. I also want to realize FaaS by Dart, but I'm about to give up due to the error of this dart compile :-(

@jarrodcolburn
Copy link
Contributor

This is interesting to see here. If I'm not mistaken, defining these models is similar to the firestore problem that the cloud_firestore_odm package tries to solve for the cloud_firestore package, that takes a different approach. Since dart:mirrors isn't available on mobile, the odm package uses a build runner step.

If there is an irony, it's that cloud_firestore_odm comes with plenty of gotchas of its own, leaving the dev wishing they could use some type of reflection... like server devs.

@jonasfj jonasfj added the type-enhancement A request for a change that isn't a bug label Jan 10, 2024
@devoncarew devoncarew transferred this issue from dart-archive/gcloud Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:gcloud type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

5 participants