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

Spanner: support custom key type encode/decode #2747

Closed
vvakame opened this issue Aug 19, 2020 · 0 comments · Fixed by #2748
Closed

Spanner: support custom key type encode/decode #2747

vvakame opened this issue Aug 19, 2020 · 0 comments · Fixed by #2748
Assignees
Labels
api: spanner Issues related to the Spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@vvakame
Copy link
Contributor

vvakame commented Aug 19, 2020

Is your feature request related to a problem? Please describe.
I wanna use custome type with spanner.Key likes #854 / #2614

expected.

type TodoID string

type Todo struct {
  TodoID TodoID
  ...
}

func Update (ctx context.Context, todo *Todo) {
  tx.ReadRow(ctx, "Todos", spanner.Key{todo.TodoID})
  ...
}

We should be write like spanner.Key{string(todo.TodoID)} now. It's annoying & easy to make bug.
compiler can't check this problem.

Describe the solution you'd like
support spanner.Encoder to keyPartValue function and Key#String method.

Describe alternatives you've considered
make utility function likes func toSpannerKey(id TodoID) spanner.Key.

Additional context
I wrote up some code to this issue. I'll submit PR to this repo.

@vvakame vvakame added the triage me I really want to be triaged. label Aug 19, 2020
@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Aug 19, 2020
@skuruppu skuruppu added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p2 Moderately-important priority. Fix may not be included in next release. and removed triage me I really want to be triaged. labels Aug 19, 2020
tritone pushed a commit to tritone/google-cloud-go that referenced this issue Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants