Skip to content

Adjusting the codegen handler order #2716

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

Closed
topazur opened this issue Sep 8, 2023 · 5 comments · Fixed by #2814
Closed

Adjusting the codegen handler order #2716

topazur opened this issue Sep 8, 2023 · 5 comments · Fixed by #2814
Labels
bug Something isn't working plugin
Milestone

Comments

@topazur
Copy link
Contributor

topazur commented Sep 8, 2023

Version

1.21.0

What happened?

repo: sqlc-gen-go-separate

I have created a plugin with the aim of changing the codegen/golang templates to meet my project requirements.

But I found that due to the order of the handlers, I cannot use the config.SQLGen field in the configuration item.

I think we should lower the priority of golang.Generate.

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@topazur topazur added bug Something isn't working triage New issues that hasn't been reviewed labels Sep 8, 2023
@topazur
Copy link
Contributor Author

topazur commented Sep 11, 2023

Hello!
I think the default generator priority should be the lowest, I don't know what you think about this?
This way, I have more possibilities for operation in the plugin configuration file.

@kyleconroy kyleconroy added plugin and removed triage New issues that hasn't been reviewed labels Oct 2, 2023
@kyleconroy kyleconroy added this to the 1.23.0 milestone Oct 2, 2023
@kyleconroy
Copy link
Collaborator

@topazur I misunderstood this issue when it was originally opened. We'll get this in for 1.23.0

@andrewmbenton
Copy link
Collaborator

I pushed a PR that I think resolves this issue.

But @topazur just so you're aware, we will be deprecating the go-specific configuration options from the codegen request proto in the near future.

@topazur
Copy link
Contributor Author

topazur commented Oct 9, 2023

@andrewmbenton Thank you, I will continue to follow the configuration options!

@andrewmbenton
Copy link
Collaborator

@topazur after doing some more testing related to extracting our Go codegen as a plugin, I realized I may not understand exactly what is going wrong for you.

cannot use the config.SQLGen field in the configuration item

Can you expand on this a little bit? Are you saying that inside of your plugin, you don't have access to the configuration options from the built-in go codegen as parsed from sqlc.yaml? Because all of those options are parsed and sent to every plugin, as part of the codegen request proto (although as mentioned we will likely be removing them). The codegen request has a Settings field with a GoCode field underneath, which has all of the configured options: https://buf.build/sqlc/sqlc/docs/main:plugin#plugin.GoCode.

But maybe there is another problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants