-
Notifications
You must be signed in to change notification settings - Fork 426
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
chore: Make ShowByID configurable in generator #2822
Conversation
Integration tests success for 258dda270a3385ded96d9e26e628abf1116f0711 |
@@ -201,7 +201,11 @@ var ViewsDef = g.NewInterface( | |||
OptionalStartsWith(). | |||
OptionalLimit(), | |||
). | |||
ShowByIdOperation(). | |||
ShowByIdOperation( |
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.
I feel like an additional layer of abstraction would be better. I think receiving an enum for common presets would be sufficient (like in the case of DescribeOperation), e.g.
// enum names could be better, but that's what I imagined it like
ShowByIdOperation(g.ShowByIdLikeFiltering)
ShowByIdOperation(g.ShowByIdInDatabaseWithLikeFiltering)
ShowByIdOperation(g.ShowByIdInSchemaWithLikeFiltering)
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 is exactly what I wanted to point out. I would even say that it would be possible to base the In
choice on the identifier type (because for schema objects with search in schema, for db objects we search in db, etc.). But the one suggested by @sfc-gh-jcieslak should be enough.
@@ -0,0 +1,26 @@ | |||
package generator | |||
|
|||
type Config struct { |
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.
Config is very generic, maybe something like ShowByIdConfig
would be better. Oh ok, I see it's made to be more generic, but as I mentioned this could be replaced most likely with enum value on Operation struct level like in the case of Describe's different "modes". wdyt?
@@ -53,6 +53,10 @@ func (v *plainStruct) OptionalNumber(dbName string) *plainStruct { | |||
return v.Field(dbName, "*int") | |||
} | |||
|
|||
func (v *plainStruct) PlainStructField(name string, plainStruct *plainStruct) *plainStruct { |
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.
It's not used anywhere (or I missed something), do you think it's needed?
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.
I used it earlier, forgot to remove.
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.
I am not leaving more implementation comments because the whole approach should be changed according to one of the above comments
Closing - it was implemented in #3227. |
Test Plan
References