Skip to content

'SELECT NOT EXISTS' queries should return bool, but doesn't #1140

Closed
@immysec

Description

@immysec

Input:

-- Example queries for sqlc
CREATE TABLE authors (
  id   BIGSERIAL PRIMARY KEY,
  name text      NOT NULL,
  bio  text
);

-- name: IsAuthorNotExist :one
select not exists(select * from authors where name = $1);

Output:

// Code generated by sqlc. DO NOT EDIT.
// source: query.sql

package db

import (
	"context"
)

const isAuthorNotExist = `-- name: IsAuthorNotExist :one
select not exists(select id, name, bio from authors where name = $1)
`

func (q *Queries) IsAuthorNotExist(ctx context.Context, name string) (interface{}, error) {
	row := q.db.QueryRowContext(ctx, isAuthorNotExist, name)
	var column_1 interface{}
	err := row.Scan(&column_1)
	return column_1, err
}

Mirror Issue: #410

Playground: https://play.sqlc.dev/p/4d3157960466fbdbbc3bc5a55f0e72e3eb8c97d4a0d84fe08b2fd13ef323c688

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions