sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.54k stars 809 forks source link

Verify: ERROR unknown query set: queryset_0 Error verifying queries: errored #3567

Open veqryn opened 2 months ago

veqryn commented 2 months ago

Version

1.27.0

What happened?

I am trying to go through the tutorial, except with my own basic queries. I get to the part where I am to try out the verify command, and get this error:

$ sqlc verify --against learning
FAIL    queryset_0
  ERROR unknown query set: queryset_0
Error verifying queries: errored

Please note that the generated model and queries work just fine.

Relevant log output

No response

Database schema

CREATE TYPE COLORS AS ENUM('red', 'green', 'blue');

CREATE TABLE accounts (
    id          BIGSERIAL PRIMARY KEY,
    name        VARCHAR(50)              NOT NULL,
    email       VARCHAR(50) UNIQUE       NOT NULL,
    active      BOOLEAN                  NOT NULL,
    fav_color   COLORS,
    fav_numbers INTEGER[],
    properties  JSONB,
    created_at  TIMESTAMP WITH TIME ZONE NOT NULL
);

INSERT INTO accounts (id, name, email, active, fav_color, fav_numbers, properties, created_at)
VALUES (1, 'Bob', 'bob@internal.com', true, 'red', '{5}', '{"tags": ["fun"]}', '2024-08-28T01:02:03Z'),
       (2, 'Jane', 'jane@internal.com', true, 'green', '{3, 19}', '{"tags": ["happy"]}', '2024-08-28T01:04:05Z'),
       (3, 'John', 'john@internal.com', false, null, '{}', '{}', '2024-08-28T01:06:07Z'),
       (4, 'Jack', 'jack@internal.com', false, null, null, null, NOW())
;

SQL queries

-- name: SelectAccountByID :one
SELECT *
FROM accounts
WHERE id = $1;

-- name: SelectAllAccounts :many
SELECT *
FROM accounts
ORDER BY id;

Configuration

version: "2"
cloud:
  project: 'myprojectid'
sql:
  - engine: "postgresql"
    queries: "query.sql"
    schema: "../data/01_schema.sql"
    gen:
      go:
        package: "model"
        out: "internal/model"
        sql_package: "pgx/v5"

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

santheipman commented 1 month ago

I have similar issue. I fixed it by add name to the config. In your case, the config should look like this:

version: "2"
cloud:
  project: 'myprojectid'
sql:
  - name: "queryName"
    engine: "postgresql"
    queries: "query.sql"
    schema: "../data/01_schema.sql"
    gen:
      go:
        package: "model"
        out: "internal/model"
        sql_package: "pgx/v5"

The error message ERROR unknown query set: queryset_0 should be improved