Duplicated Query Name even when there is no duplicate.
Version
1.26.0
What happened?
I'm just strarting to explore this tool and added a couple tables and some more queries straight from tutorial and... it's broken. Not sure if I did something wrong and the error message is misleading or it is an actual bug.
Since so many ppl use this in production, I probably did something wrong ... it shouldn't break at this most basic function. Please let me know.
Relevant log output
sqlc generate failed.
# package
query.sql:1:1: duplicate query name: GetAuthorr
Database schema
CREATE TABLE authors
(
id INTEGER PRIMARY KEY,
name text NOT NULL,
bio text
);
CREATE TABLE books
(
id INTEGER PRIMARY KEY,
title text NOT NULL,
author_id INTEGER REFERENCES authors (id),
isbn text NOT NULL,
summary text
);
create table users
(
id INTEGER PRIMARY KEY,
username text NOT NULL,
password text NOT NULL
);
create table borrowings
(
id INTEGER PRIMARY KEY,
user_id INTEGER REFERENCES users (id),
book_id INTEGER REFERENCES books (id),
due_at timestamp with time zone,
return_at timestamp with time zone
);
SQL queries
-- name: GetAuthorr :one
SELECT * FROM authors
WHERE id = ? LIMIT 1;
-- name: ListAuthors :many
SELECT * FROM authors
ORDER BY name;
-- name: CreateAuthor :one
INSERT INTO authors (
name, bio
) VALUES (
?, ?
)
RETURNING *;
-- name: UpdateAuthor :exec
UPDATE authors
set name = ?,
bio = ?
WHERE id = ?
RETURNING *;
-- name: DeleteAuthor :exec
DELETE FROM authors
WHERE id = ?;
-- name: ListAuthorNames :many
SELECT name FROM authors
-- name : GetBook :one
SELECT * FROM books
WHERE id = ? LIMIT 1;
-- name: ListBooks :many
SELECT books.* FROM books
left join authors on books.author_id = authors.id
ORDER BY title;
Configuration
{
"version": "2",
"sql": [{
"schema": "schema.sql",
"queries": "query.sql",
"engine": "sqlite",
"gen": {
"go": {
"out": "db"
}
}
}]
}
Playground URL
https://play.sqlc.dev/p/0f9fdcf11ecc131bd4990a3e4e2a296ad094a94d08a3841344da936a8c43417e
What operating system are you using?
No response
What database engines are you using?
No response
What type of code are you generating?
No response
It will work if you add ; to the end of the ListAuthorNames query. The error is misleading.
https://play.sqlc.dev/p/9cbc0268b59a3ba7776ebea62d94e330dd142b8e78bb05d0306f2ad07da22477
Its better to update the error message showing that there should be a colon that is missing rather than showing this error message.
I would suggest Instead of error message duplicate query name.
- # package
- sql/queries/windows.sql:1:1: duplicate query name: ListAllWindows
+ # package
+ sql/queries/windows.sql:1:17: missing semicolon in query: ListAllWindows
missing semicolon is better error message than duplicate query name