-
Notifications
You must be signed in to change notification settings - Fork 962
Duplicate query name error generating sqlite code #1872
Unanswered
mrjawright
asked this question in
Q&A
-
I understand that sqlite support is still in Beta, but I'm hoping this is something easy to fix on my end that I'm just overlooking.
I'm trying to do a POC on a simple database, but whenever I run generate i get resources/query.sql:1:1: duplicate query name: GetUserByUserId. It doesn't matter what I change the query name to, it always get the same error.
my query.sql:
-- name: GetUserByUserId :one
SELECT email, first_name, last_name, user_id
FROM users
WHERE user_id = ?;
-- name: GetAllUsers :many
SELECT email, first_name, last_name, user_id
FROM users;
-- name: GetRolesByUserId :many
SELECT rd.role FROM user_roles ur
INNER JOIN role_definitions rd ON rd.type = ur.role
WHERE ur.user_id = ?
-- name: GetUserByEmailAndPassword :one
SELECT email, first_name, last_name, user_id
FROM users
WHERE email = ? AND password = ?;
-- name: GetUserByEmail :one
SELECT email, first_name, last_name, user_id, password
FROM users
WHERE email = ?;
-- name: CreateUser :one
INSERT INTO users (email, first_name, last_name, user_id, password)
VALUES (?, ?, ?, ?, ?)
RETURNING *;
-- name: CreateUserRole :one
INSERT INTO user_roles (user_id, designation)
VALUES (?, ?)
RETURNING *;
-- name: DeleteUser :exec
DELETE
FROM users
WHERE user_id = ?;
-- name: UpdateUser :one
UPDATE users
SET email = ?, first_name = ?, last_name = ?
WHERE user_id = ?
RETURNING *;
Edit: this is what happens when you have more than one table and the queries aren't grouped by table. Makes sense in retrospect, but maybe you could have more than one table in the tutorial so that was a little more obvious?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment