Skip to content

UNION creates duplicate fields #1546

Closed
Closed
@esenmx

Description

@esenmx

Version

1.12.0

What happened?

Generated code:

type CreateACRow struct {
	Foo   int32
	Foo_2 int32
	Bar   sql.NullInt32
}

Similar to #568. It always creates duplicate fields with _2 suffix. Using DISTINCT also does not work, checked the #896, it's not supported anyway.

Relevant log output

No response

Database schema

create table a
(
    foo int primary key
);

create table c
(
    bar int
);

SQL queries

-- Simple Example
select * from ((select * from a limit 1) union (select * from c limit 1)) as ac;

-- My Case
with x as (insert into a (foo) values ($1) returning *),
     y as (insert into c (bar) values ($2) returning *)
select *
from ((select * from x) union (select * from y)) as ac;

Configuration

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

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