Skip to content

Unions in Postgres result in error #843

Closed
@honne23

Description

@honne23

Hey all!

I'm loving sqlc as it's greatly reducing my dev-time but I've run into an issue and I'm not sure if I've misunderstood the API or not.

I essentially have a couple of tables that hold a bunch of enums for a few reusable values (i.e listing_type can only take on the value of one of 3 strings, so these strings are stored in their own table and are referenced as foreign keys).

Anyway, I wanted to write a query that just grabs all the enums from all the tables and unions them into a single table rather than a select * from statement for each table as so:

-- name: GetAllEnums :many
SELECT * FROM payment_terms
UNION
SELECT * FROM collection_terms
UNION
SELECT * FROM packaging_type
UNION
SELECT * FROM load_type
UNION
SELECT * FROM price_type
UNION
SELECT * FROM listing_type;

However this throws the following error:
error generating code: template: table:255:79: executing "queryCode" at <.Ret.Type>: error calling Type: no type for QueryValue:

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    📚 postgresqlbugSomething isn't workingduplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions