Skip to content

Add a NULL value to a varchar array #1638

Open
@nakem1

Description

@nakem1

Version

1.13.0

What happened?

I have a query

-- name: Test :exec
INSERT INTO test (id, body)
VALUES (
  UNNEST($1::uuid[]), UNNEST($2::varchar[]));

there is a generated struct

type TestParams struct {
	Column1     []uuid.UUID   `json:"column_1"`
	Column2     []string          `json:"column_2"`
}

sometimes i need to pass to body a null value. I can't pass NULL to string.
As a quick fix, I changed the generated file. Yes, I know it's a crime against humanity, but it solves my problem:))

I changed []string -> []interface{} in the TestParams struct.

Relevant log output

No response

Database schema

create table test
(
    id            uuid                                                 not null,
    body          varchar,
)

SQL queries

No response

Configuration

No response

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