Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Relation does not exist on update only #3852

Open
Labels
📚 sqlite bugSomething isn't working
@dimmerz92

Description

Version

1.28.0

What happened?

Expected sqlc generate to generate all queries.

I tried removing queries one by one and found that generating worked for everything except for UPDATE statements.

No issues in sqlc playground.

Relevant log output

# package models
sql/queries/users.sql:45:1: relation "Users" does not exist
sql/queries/users.sql:53:1: relation "Users" does not exist

Database schema

-- +goose Up
CREATE TABLE Users (
	ID INTEGER PRIMARY KEY,
	FullName TEXT NOT NULL,
	Email TEXT UNIQUE NOT NULL CHECK (Email LIKE '%_@%_.%__'),
	Password BLOB NOT NULL,
	CreatedAt INTEGER NOT NULL DEFAULT (unixepoch('now')),
	UpdatedAt INTEGER
);
-- +goose StatementBegin
CREATE TRIGGER UpdateUser
AFTER UPDATE ON Users
BEGIN
	UPDATE
		Users
	SET	
		UpdatedAt = unixepoch('now')
	WHERE
		ID = NEW.ID;
END;
-- +goose StatementEnd
-- +goose Down
DROP TABLE Users;

SQL queries

-- name: AddUser :one
INSERT INTO Users (
	FullName,
	Email,
	Password
)
VALUES (
	@FullName,
	@Email,
	@Password
)
RETURNING
	*;
-- name: CheckEmailExists :one
SELECT
	1
FROM
	Users
WHERE
	Email = @email;
-- name: GetUser :one
SELECT
	*
FROM
	Users
WHERE
	ID = @userID OR
	Email = @email;
-- name: GetPaginatedUsers :many
SELECT
	*
FROM
	Users
ORDER BY
	ID
LIMIT
	@limit
OFFSET
	@offset;
-- name: UpdateEmail :exec
UPDATE
	Users
SET
	Email = @email
WHERE
	ID = @userID;
-- name: UpdatePassword :exec
UPDATE
	Users
SET
	Password = @password
WHERE
	ID = @userID;
-- name: DeleteUser :exec
DELETE FROM
	Users
WHERE
	ID = @userID;

Configuration

version: 2
sql:
 - engine: sqlite
 queries: sql/queries
 schema: sql/schema
 gen:
 go:
 package: models
 out: models

Playground URL

https://play.sqlc.dev/p/0fa9a40b4593ee2b4dd899dd126591b50bf92961b5f13c41372b4eab4d0ea668

What operating system are you using?

macOS

What database engines are you using?

SQLite

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    📚 sqlite bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /