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

Add stand_alone_name configuration for each queries #2627

Closed

Conversation

michaelzx
Copy link

Description

This PR adds the string configuration sql.gen.go.stand_alone_name in sqlc.yaml.

Features

  1. The program will not generate the db.go file
  2. Merge the original code in db.go into each queries.go file, combine into one file
  3. In the new queries.go file, stand_alone_name will be used to differentiate DBTX, New, Queries, and sql constants

Examples

I have put examples in the examples/stand_alone_name directory, including schema.sql, queries.sql, sqlc.yaml, and the generated go files
Development environment:
Mac, go 1.19.3, PostgreSQL 14

Note

I have not done complete testing, this is just to provide a reference idea

@kyleconroy
Copy link
Collaborator

@michaelzx Appreciate you putting together a complete working example for reference. As of right now, we won't be accepting a change like this. Single configuration options that change that dramatically change the structure of the code are difficult to maintain, as they interact with the other configuration options in difficult to understand ways.

I hope that in a few versions codegen plugins will be a bit easier to write and you can implement your idea via that mechanism.

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