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: Support Custom Marsheling and Unmarsheling #1416

Closed
giautm opened this issue May 2, 2019 · 11 comments
Closed

Firestore: Support Custom Marsheling and Unmarsheling #1416

giautm opened this issue May 2, 2019 · 11 comments
Assignees
Labels
api: firestore Issues related to the Firestore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@giautm
Copy link

giautm commented May 2, 2019

I wish firestore support custom data type as (google/uuid) via custom marshal/unmarshal.

Currently: firestore: cannot convert type uuid.UUID to value

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label May 3, 2019
@jeanbza jeanbza added api: firestore Issues related to the Firestore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed triage me I really want to be triaged. labels May 3, 2019
@jeanbza
Copy link
Contributor

jeanbza commented May 3, 2019

Could you provide a small code snippet how you're passing google/uuid to firestore?

@jeanbza jeanbza added the needs more info This issue needs more information from the customer to proceed. label May 3, 2019
@giautm
Copy link
Author

giautm commented May 4, 2019

I added a field named ID to structure. Then ran into the error.

type State struct {
	ID         uuid.UUID `firestore:"id"`
	Capital    string    `firestore:"capital"`
	Population float64   `firestore:"pop"` // in millions
}

@giautm
Copy link
Author

giautm commented May 7, 2019

Hi @jadekler , Do you have any comment?

@jeanbza jeanbza removed the needs more info This issue needs more information from the customer to proceed. label May 8, 2019
@jeanbza
Copy link
Contributor

jeanbza commented May 8, 2019

Looks like the issue is that we don't handle arrays properly (uuid.UUID is a byte array). I've submitted a CL to fix this: https://code-review.googlesource.com/c/gocloud/+/40996

@giautm
Copy link
Author

giautm commented May 10, 2019

Yes, This fix worked. But not the way that I want. UUID was converted to an array of bytes.

image

@jeanbza
Copy link
Contributor

jeanbza commented May 10, 2019

Right, that's because uuid.UUID is an array of bytes. :) If you're looking for a string representation, you will have to change the type and do the string conversion yourself.

@giautm
Copy link
Author

giautm commented May 10, 2019

@jadekler : If firestore support encoding(https://golang.org/pkg/encoding/) package, we can do it easier

@giautm
Copy link
Author

giautm commented May 10, 2019

Hi @jadekler , I created a PR to support encoding/text https://github.com/googleapis/google-cloud-go/pull/1425/files

@marwan-at-work
Copy link

marwan-at-work commented Jun 24, 2019

@giautm @jadekler I stumbled upon this for a similar (but not exact) reason: it would be really helpful if the client also supported custom JSON Marshaler/Unmarshaler interfaces

Do you mind re-opening this issue or maybe I can create a new/separate issue for it? Thanks

@jeanbza
Copy link
Contributor

jeanbza commented Jun 24, 2019

@marwan-at-work Yes, please file a new issue.

@marwan-at-work
Copy link

@jadekler done (#1475)
thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the Firestore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

5 participants