sqlc-dev / sqlc

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

:one without results is supposed to return "sql: no rows in result set" which is the same as database/sql.ErrNoRows but returning "no rows in result set" #3618

Closed ezekielchow closed 1 month ago

ezekielchow commented 1 month ago

Version

1.27.0

What happened?

Go version: 1.22.5

Error returned for :one query without results doesn't match database/sql.ErrNoRows

Relevant log output

No response

Database schema

CREATE TABLE IF NOT EXISTS users (
    id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
    email varchar(255) NOT NULL,
    password_hash text,
    created_at timestamp DEFAULT now(),
    updated_at timestamp 
);

SQL queries

-- name: FindUserWithEmail :one
SELECT * FROM users WHERE email=$1;

Configuration

version: "2"
sql:
  - engine: "postgresql"
    queries: "query.sql"
    schema: "../../migrations"
    gen:
      go:
        package: "userstoregenerated"
        out: "./generated"
        sql_package: "pgx/v5"
        emit_pointers_for_null_types: true

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Jille commented 1 month ago

I think that's because of pgx. You just either match against pgx.ErrNoRows or use errors.Is()

ezekielchow commented 1 month ago
```sql
SELECT * FROM users WHERE email=$1;

Ahh yes. Checked and found that. Will be closing this issue then. Thank you