Skip to content

Source files not generating when query file name contains underscore #4109

@nishant230701

Description

@nishant230701

Version

1.30.0

What happened?

Created sql/schema/003_feed_follows.sql and a sql/queries/feed_follows.sql. The FeedFollow struct was created in internal/database/models.go but the feed_follows.sql.go file was not generated which was unexpected. Deleting all the generated files, renaming the sql/queries/feed_follows.sql to sql/queries/follows.sql and running sqlc generate worked.

Relevant log output

Database schema

-- +goose Up
CREATE TABLE users (
    id UUID NOT NULL PRIMARY KEY,
    created_at TIMESTAMP NOT NULL,
    updated_at TIMESTAMP NOT NULL,
    name VARCHAR(256) UNIQUE NOT NULL
);

-- +goose Up
CREATE TABLE feeds (
    id UUID NOT NULL PRIMARY KEY,
    created_at TIMESTAMP NOT NULL,
    updated_at TIMESTAMP NOT NULL,
    name VARCHAR(256) NOT NULL,
    url VARCHAR(1024) NOT NULL UNIQUE,
    user_id UUID NOT NULL,
    CONSTRAINT feed_created_by FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);

-- +goose Down
DROP TABLE feeds;


-- +goose Down
DROP TABLE users;

-- +goose Up
CREATE TABLE feed_follows (
    id UUID NOT NULL PRIMARY KEY,
    created_at TIMESTAMP NOT NULL,
    updated_at TIMESTAMP NOT NULL,
    user_id UUID NOT NULL,
    feed_id UUID NOT NULL,
    CONSTRAINT feed_follower FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
    CONSTRAINT feed_followed FOREIGN KEY (feed_id) REFERENCES feeds(id) ON DELETE CASCADE,
    UNIQUE (user_id, feed_id)
);

-- +goose Down
DROP TABLE feed_follows;

SQL queries

-- name: CreateFeedFollow :one
INSERT INTO feed_follows (id, created_at, updated_at, user_id, feed_id)
VALUES($1, $2, $3, $4, $5)
RETURNING *;

Configuration

version: "2"
sql:
  - schema: "sql/schema"
    queries: "sql/queries"
    engine: "postgresql"
    gen:
      go:
        out: "internal/database"

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions