Skip to content

Commit

Permalink
fix(ORM): support for imported messages in iterators (#11372)
Browse files Browse the repository at this point in the history
## Description

- adds support for imported messages in iterators

Closes: n/a



---

### 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...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [x] provided a link to the relevant issue or specification
- [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/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)
  • Loading branch information
technicallyty authored Mar 14, 2022
1 parent 18a8162 commit 0a3298f
Show file tree
Hide file tree
Showing 7 changed files with 878 additions and 52 deletions.
10 changes: 9 additions & 1 deletion orm/encoding/encodeutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ func ValuesOf(values ...interface{}) []protoreflect.Value {
n := len(values)
res := make([]protoreflect.Value, n)
for i := 0; i < n; i++ {
res[i] = protoreflect.ValueOf(values[i])
// we catch the case of proto messages here and call ProtoReflect.
// this allows us to use imported messages, such as timestamppb.Timestamp
// in iterators.
value := values[i]
switch value.(type) {
case protoreflect.ProtoMessage:
value = value.(protoreflect.ProtoMessage).ProtoReflect()
}
res[i] = protoreflect.ValueOf(value)
}
return res
}
1 change: 0 additions & 1 deletion orm/internal/testpb/bank.cosmos_orm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions orm/internal/testpb/bank.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

146 changes: 145 additions & 1 deletion orm/internal/testpb/test_schema.cosmos_orm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions orm/internal/testpb/test_schema.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,15 @@ message ExampleSingleton {
string foo = 1;
int32 bar = 2;
}

message ExampleTimestamp {
option (cosmos.orm.v1alpha1.table) = {
id: 4
primary_key: {fields: "id" auto_increment: true}
index: {id: 1 fields: "ts"}
};

uint64 id = 1;
string name = 2;
google.protobuf.Timestamp ts = 3;
}
Loading

0 comments on commit 0a3298f

Please sign in to comment.