sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

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

Open veqryn opened this issue 1 year ago • 3 comments

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', '[email protected]', true, 'red', '{5}', '{"tags": ["fun"]}', '2024-08-28T01:02:03Z'),
       (2, 'Jane', '[email protected]', true, 'green', '{3, 19}', '{"tags": ["happy"]}', '2024-08-28T01:04:05Z'),
       (3, 'John', '[email protected]', false, null, '{}', '{}', '2024-08-28T01:06:07Z'),
       (4, 'Jack', '[email protected]', 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

veqryn avatar Sep 01 '24 07:09 veqryn

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

santheipman avatar Sep 30 '24 04:09 santheipman

I followed the same tutorial but now getting another error even after setting a name attribute.

sqlc verify --against tutorial
FAIL    queryName
  ERROR no PostgreSQL database server found
Error verifying queries: errored

Is there any other config attribute missing?

version: "2"
cloud:
  project: 'XXXX'
sql:
  - name: "queryName"
    engine: "postgresql"
    queries: "query.sql"
    schema: "migrations/"
    gen:
      go:
        package: "tutorial"
        out: "tutorial"
        sql_package: "pgx/v5"

Kogoro avatar Aug 03 '25 15:08 Kogoro

@Kogoro So I managed to fix this in a roundabout way. I'm not exceedingly familiar with sqlc yet; I could be missing something with respect to the in-line databases that sqlc generates.

That being said, if you have a postgresql db running, you can fix this with the following:

servers:
  - engine: postgresql
    uri: "postgres://${PG_USERNAME}:${PG_PASSWORD}@localhost:5432/{$DB_NAME}"

Replace the relevant parts of this URI with your db name, username, and password (or set them to environment variables like I have them here). Once this is done, set managed: true inside the sql connection, and you'll have a yaml file similar to this:

cloud:
  # Replace <PROJECT_ID> with your project ID from the sqlc Cloud dashboard
  project: "XXX"
servers:
  - engine: postgresql
    uri: "postgres://${PG_USERNAME}:${PG_PASSWORD}@localhost:5432/{$DB_NAME}"
sql:
  - name: "tutorial"
    engine: "postgresql"
    queries: "query.sql"
    schema: "schema.sql"
    database:
      managed: true
    gen:
      go:
        package: "tutorial"
        out: "tutorial"
        sql_package: "pgx/v5"

thelexibelle avatar Dec 04 '25 02:12 thelexibelle