Skip to content

Support composite types #2760

Open
@kyleconroy

Description

@kyleconroy

CREATE TYPE

CREATE TYPE myarg as (
    id integer,
    name text
);

-- name: BasicQuery :one
select $1::myarg;

Automatic table types

https://www.postgresql.org/docs/current/rowtypes.html

Whenever you create a table, a composite type is also automatically created, with the same name as the table, to represent the table's row type. For example, had we said:

CREATE TABLE authors (
  id   BIGSERIAL PRIMARY KEY,
  name text      NOT NULL,
  bio  text
);

-- name: AutomatiicType :many
select authors from authors;

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