Skip to content

Struct representing return type of a select query not generated #2127

Closed
@Archisman-Mridha

Description

@Archisman-Mridha

Version

1.16.0

What happened?

I have this postgresql query -

SELECT (email, username) FROM users
    WHERE users.email= @email OR users.username= @username
        LIMIT 1;

and I am trying to generate GoLang code.

sqlc doesn't generate a struct representing (email, username). Instead, it just creates interface{ }.

Relevant log output

No response

Database schema

CREATE TABLE users (
    id SERIAL PRIMARY KEY,

    email VARCHAR(255) NOT NULL UNIQUE,
    username VARCHAR(50) NOT NULL UNIQUE,
    password VARCHAR(50) NOT NULL
);

SQL queries

SELECT (email, username) FROM users
    WHERE users.email= @email OR users.username= @username
        LIMIT 1;

Configuration

version: "2"

sql:
    - engine: postgresql
      queries: ./sql/queries.sql
      schema: ./sql/schema.sql
      gen:
        go:
            package: sqlc
            out: ./generated/sqlc
            emit_interface: true

Playground URL

https://play.sqlc.dev/p/0210bd42a17a0804f628d75bd58e69757e9be888a4f9ed713f8acaaa1cbd49d3

What operating system are you using?

Linux

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