Skip to content

Configuration file, package key conflict with - #3982

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
d-kja opened this issue Jun 6, 2025 · 0 comments
Closed

Configuration file, package key conflict with - #3982

d-kja opened this issue Jun 6, 2025 · 0 comments

Comments

@d-kja
Copy link

d-kja commented Jun 6, 2025

Version

1.29.0

What happened?

Issue

When you're creating a new sqlc.yaml file, if you use a - in the name of the package, a compilation error will occur. The main issue here is that the error message doesn't help understand the problem.

Example

Let's say I want a random name like orders-gen or something like that:

version: "2"
sql:
  - engine: "postgresql"
    queries: "query.sql"
    schema: "schema.sql"
    gen:
      go:
        package: "orders-gen"
        out: "tutorial"
        sql_package: "pgx/v5"

This configuration will raise the following error:

Image

Now, if you change orders-gen to orders_gen, it works just fine.

Why?

Let's analyze the error message.

error generating code: source error: 7:15: expected ';', found '-'

It clearly says that I'm using a - and that it was expecting a ;? It lacks information. Where is the issue? Is it related to my SQL code, or is it the configuration file? No clue.

If you aren't aware of that fact, you might end up spending a couple of hours trying to figure out the problem. My "solution" is to either make the conventions of the compiler clear during the tutorial or improve the error handling to give a better experience to anyone using the package.

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@d-kja d-kja added the bug Something isn't working label Jun 6, 2025
@d-kja d-kja closed this as completed Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant