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

Improve type check of keys #26

Closed
kuy opened this issue Jul 5, 2020 · 1 comment
Closed

Improve type check of keys #26

kuy opened this issue Jul 5, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@kuy
Copy link
Collaborator

kuy commented Jul 5, 2020

Is your feature request related to a problem? Please describe.

In a table which has both partition key and sort key, rustc doesn't raise errors if I forget to call sort_key(...) method to pass sort key.

Describe the solution you'd like

raiden-derive could generate more precise signatures like fn get(&mut self, key: (K, K)) where K: IntoAttribute + Send instead of fn get(&mut self, key: impl IntoAttribute + Send) base on given definition of the struct.

Want to discuss

Abstract Key

In batch_get op, there are lots of conditional code generations like below.

https://github.com/raiden-rs/raiden/blob/94a77a238405acca7a048d397a6347297b7768b1/raiden-derive/src/ops/batch_get.rs#L73-L90

I want to reduce repeat by defining an abstract type for keys. This means that the type consists of impl IntoAttribute and (impl IntoAttribute, impl IntoAttribute). If I define the abstract type using enum, it looks like below.

enum Key {
  Pk(impl IntoAttribute),
  PkSk((impl IntoAttribute, impl IntoAttribute)),
}

However, this is annoying in its representation.

let keys = vec![("aaa", 2019), ("bbb", 2020), ("ccc", 2021)]; // looks naturally

let keys = vec![PkSk("aaa", 2019), PkSk("bbb", 2020), PkSk("ccc", 2021)]; // umm....

So finally, I stopped this approach.

@kuy
Copy link
Collaborator Author

kuy commented Jul 5, 2020

Tackle after #14

@bokuweb bokuweb added the enhancement New feature or request label Jul 7, 2020
@kuy kuy self-assigned this Jul 9, 2020
@kuy kuy mentioned this issue Jul 9, 2020
3 tasks
@kuy kuy closed this as completed Jul 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants