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 optional fields #12

Open
fdymylja opened this issue Jul 22, 2021 · 6 comments
Open

Support optional fields #12

fdymylja opened this issue Jul 22, 2021 · 6 comments

Comments

@fdymylja
Copy link
Contributor

The plugin currently does not support optional fields:

testpb/1.proto: is a proto3 file that contains optional fields, but code generator protoc-gen-go-fasteflection hasn't been updated to support optional fields in proto3.
@technicallyty
Copy link
Contributor

it works in the main branch, but you need to pass --experimental_allow_proto3_optional

@technicallyty
Copy link
Contributor

iceboxing this as we are not planning to support optional fields at this time

@aaronc
Copy link
Member

aaronc commented Jan 25, 2022

I think it's worth reopening this as I'm seeing some use cases for optional fields. How hard do you think it will be to add?

@aaronc
Copy link
Member

aaronc commented Jan 25, 2022

Btw, pulsar codegen does not fail for me and generates the expected *int32 pointer type. But build does fail:

regen/ecocredit/curation/v1beta1/state.pulsar.go:662:6: x.XMin undefined (type *fastReflection_NumericAttributeDefinition has no field or method XMin)
regen/ecocredit/curation/v1beta1/state.pulsar.go:663:16: x.XMin undefined (type *fastReflection_NumericAttributeDefinition has no field or method XMin)
regen/ecocredit/curation/v1beta1/state.pulsar.go:664:9: undefined: NumericAttributeDefinition_Min

@fdymylja
Copy link
Contributor Author

It's complex due to presence semantics.

I will add it to the backlog, what is the priority?

@aaronc
Copy link
Member

aaronc commented Jan 25, 2022

I would consider it low as I can make a work-around

@aaronc aaronc moved this from Todo to Ice Box in Cosmos SDK: Framework WG Mar 29, 2022
@aaronc aaronc moved this from Ice Box to Backlog in Cosmos SDK: Framework WG Apr 12, 2022
mergify bot pushed a commit to cosmos/cosmos-sdk that referenced this issue Oct 7, 2022
## Description

This starts the implementation of approach (C) in #11774 by generating `_query.proto` files for `.proto` files which have ORM definitions. It does this using a new protoc plugin called `protoc-gen-go-cosmos-orm-proto`.

Please review `bank_query.proto` and `test_schema_query.proto` as these are the outputs of the codegen.

The approach taken does not attempt to do any sort of logical queries as discussed in #11774 and instead provides direct index access in the most simple and complete way that we can easily implement now. More advanced things in #11774 could be implemented later, but this should be possible to deliver relatively quickly and should allow developers to completely skip writing gRPC queries manually if they use ORM.

Note that the implementation of these queries can provide merkle proofs because the mapping to state is well known.

I did need to disable pulsar codegen in this PR because it doesn't support proto3 optionals which are needed here (depends on cosmos/cosmos-proto#12). Fortunately, pulsar is 100% compatible with the official google codegen and there is no problem running ORM tests against the official codegen.



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed 
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
@tac0turtle tac0turtle moved this to 👀 To Do in Cosmos-SDK Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Backlog
Development

No branches or pull requests

4 participants