Skip to content

SELECT FROM queries return template error #1676

Closed
@Threpio

Description

@Threpio

Version

1.13.0

What happened?

(Preface: I know I am being a little stupid)

In queries.sql I wrote the following query:

-- name: listlegalsets :many
SELECT FROM legalsets LIMIT 500;

Whilst writing out a large number of basic queries I missed out the Asterisk (*) from the above query. The error that I got from running sqlc generate was the following:

 ✘ theoa@Theos-MacBook-Pro  ~/GolandProjects/awesomeProject2/data  sqlc generate
# package query
error generating code: template: queryCode.tmpl:51:79: executing "queryCodeStd" at <.Ret.DefineType>: error calling DefineType: no type for QueryValue: 

I understand that the error is a simple one as a result of bad SQL but is there any chance this error can be made clearer? (5 mins of my life I wasted to my own stupidity)

I would much prefer if it generated an error message that determined WHICH query was bad:

error generating code: template: error calling DefineType: no type for QueryValue: QueryName: XXX

Relevant log output

error generating code: template: queryCode.tmpl:51:79: executing "queryCodeStd" at <.Ret.DefineType>: error calling DefineType: no type for QueryValue:

Database schema

create table legalsets (
    id uuid not null primary key default gen_random_uuid(),
    name text not null unique
);

SQL queries

-- name: listlegalsets :many
SELECT FROM legalsets LIMIT 500;

Configuration

version: 1
packages:
  - path: "query"
    name: "query"
    engine: "postgresql"
    schema: "schema.sql"
    queries: "queries.sql"

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

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