Skip to content

Creating a view with a UNION no longer compiles #2664

Closed
@sergeleger

Description

@sergeleger

Version

1.20.0

What happened?

Upgraded to sqlc 1.20.0 and a view that was previously compiling under 1.18.0 now creates an error column reference "name" is ambiguous

-- `union` works in sqlc 1.18.0, 1.19.0 and 1.19.1
create view all_staff as
    select name, lname, pos from employees
    union 
    select name, lname, title as pos from managers;

Also, while investigating this bug noticed that union and union all have different error handling in versions prior to 1.20.0.

Relevant log output

# package db
query.sql:15:12: column reference "name" is ambiguous

Database schema

create table employees (
    name  text,
    lname text,
    pos   text
);

create table managers (
    name  text,
    lname text,
    title text
);

SQL queries

No response

Configuration

No response

Playground URL

https://play.sqlc.dev/p/48bae081f4aec4493fb0f202219c82267c25358eace80b7841679034b1c1a82d

What operating system are you using?

Linux

What database engines are you using?

SQLite

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNew issues that hasn't been reviewed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions