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

chore: Make ShowByID configurable in generator #2822

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sfc-gh-jmichalak
Copy link
Collaborator

Test Plan

  • acceptance tests

References

Copy link

Integration tests success for 258dda270a3385ded96d9e26e628abf1116f0711

@@ -201,7 +201,11 @@ var ViewsDef = g.NewInterface(
OptionalStartsWith().
OptionalLimit(),
).
ShowByIdOperation().
ShowByIdOperation(
Copy link
Collaborator

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)

Copy link
Collaborator

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 {
Copy link
Collaborator

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 {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator

@sfc-gh-asawicki sfc-gh-asawicki left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants