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

SQLC Fails to Recognize api_key Column During Code Generation #3790

Open
thespecialone1 opened this issue Jan 16, 2025 · 2 comments
Open

SQLC Fails to Recognize api_key Column During Code Generation #3790

thespecialone1 opened this issue Jan 16, 2025 · 2 comments

Comments

@thespecialone1
Copy link

thespecialone1 commented Jan 16, 2025

I'm encountering an issue where SQLC fails to generate code for a query involving the api_key column in my users table. Here's the context:

  1. SQL Query File (user.sql):

    -- name: CreateUser :one
    INSERT INTO users(id, created_at, updated_at, name, api_key)
    VALUES($1, $2, $3, $4, 
        encode(sha256(random()::text::bytea), 'hex')
    )
    RETURNING *;
    
    -- name: GetUserByApiKey :one
    SELECT * FROM users WHERE api_key = $1;
  2. Issue Encountered:

    When running sqlc generate, I get the following error:

    sql/queries/user.sql:9:27: column "api_key" does not exist
    
  3. What I've Tried:

    • Verified that the api_key column exists in the database using \d+ users.
    • Confirmed the table schema is correct and api_key is present as a character varying(64) column.
Image
@snowtoslow
Copy link

Hey, not sure that I will be able to help you, but can you also share your schema file?

@thespecialone1
Copy link
Author

These are my schema files

Image

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

No branches or pull requests

2 participants