-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
feat(orm): codegen #11033
feat(orm): codegen #11033
Conversation
…-sdk into aaronc/orm-codegen
We also need HasByU64Str(u64 uint64, str string) (found bool, err error)
GetByU64Str(u64 uint64, str string) (*ExampleTable, err error) |
Actually for constructors, I think we want to pass in func NewBalanceStore(db ormdb.ModuleDB) (BalanceStore, error) {
table := db.GetTable(&Balance{})
if table == nil {
return nil, fmt.ErrorF("table %s not found", (&Balance{}).ProtoReflect().Descriptor().FullName())
}
return &balanceStore{table}, nil
}
func NewStateStore(db ormdb.ModuleDB) (StateStore, error) {
balanceStore, err := NewBalanceStore(db)
if err != nil {
return nil, err
}
...
} |
@fdymylja I know you used pluralization in your codegen example on the file-level interfaces (i.e. |
…into ty/orm-codegen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting close!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great and I think is basically done 👍. Just needs a little tidying up and then I think it's ready to go.
We can deal with pagination in a follow up and I think I want to clean up a little bit the Table
interface under the hood, but that should also be in follow-ups.
Codecov Report
@@ Coverage Diff @@
## master #11033 +/- ##
==========================================
+ Coverage 65.86% 66.09% +0.22%
==========================================
Files 644 691 +47
Lines 65630 69586 +3956
==========================================
+ Hits 43229 45990 +2761
- Misses 19920 20793 +873
- Partials 2481 2803 +322
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Two things (nonblocking):
- I'd drop the suffix
Store
on bankStore.BalanceStore() - fine with it not being plural. - Need to add a note that in case state is split across multiple files the
store interfaces set (bankstore)
will not be generated correctly.
When I tried using it when it was just
Why won't it be generated correctly? |
If we have |
In this case you will end up with two file-level interfaces: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
adds orm code generation
Closes: #10737
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...
!
to the type prefix if API or client breaking changeCHANGELOG.md
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...
!
in the type prefix if API or client breaking change