Skip to content

Support for Automatically Generating Code for Multiple Directories and Packages in sqlc #3722

Open
@MatthewAraujo

Description

@MatthewAraujo

What do you want to change?

Question:

Hi, I’m using sqlc in my project, and I have a modular service structure like this:

service/
├── auth/
├── customers/
├── products/
├── orders/

Each service has its own queries.sql file, and I would like the generated Go files (e.g., auth.sql.go, customers.sql.go, etc.) to be placed in their respective directories with the correct package name.

Currently, I need to create separate blocks in the sqlc.yml file for each service manually, like this:

- engine: "postgresql"
  schema: "./cmd/migrate/migrations/schema.sql"
  queries: "./service/auth/queries.sql"
  gen:
    go:
      package: auth
      out: "./service/auth"

This works, but it can get repetitive as the number of services grows.

My question is:
Does sqlc plan to support a way to automatically detect and generate code for multiple directories and packages based on the queries.sql file location? For example, if queries.sql is in service/customers/, the generated code would automatically go to service/customers/ with the customers package name.

If not, is this something that could be considered for future releases?

What database engines need to be changed?

No response

What programming language backends need to be changed?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions