Skip to content

Postgres: Support inherited table schema #403

@ivanvanderbyl

Description

@ivanvanderbyl

When using table inheritance in Postgres, sqlc can't reference any columns in the parent table.

Example setup (from pg_dump):

-- schema.sql
CREATE TABLE public.reservations (
    id character varying(255) NOT NULL,
);

CREATE TABLE public.flight_reservations (
    flight_id character varying(255)
)
INHERITS (public.reservations);
-- queries.sql
-- name: InsertFlightReservation :one
insert into flight_reservations (id, flight_id)
VALUES ($1,
        $2) RETURNING (id);

Result:

sqlc generate
# package data
queries.sql:111:38: column "id" does not exist

Expected:

The expected result should be to reference the inherited table columns.

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