Closed
Description
Experimenting with the latest sqlc on an existing db, I'm hitting an error where it cannot find sequences. Here is a stripped down example
$ sqlc generate
# package .
schema.sql:19:1: relation "authors_id_seq" does not exist
Line 19 is an alter sequence line (note that ALTER TABLE is also valid here, see the Notes section in https://www.postgresql.org/docs/10/sql-altersequence.html):
ALTER SEQUENCE authors_id_seq
schema.sql
CREATE TABLE authors
(
id integer PRIMARY KEY,
name text NOT NULL,
bio text
);
CREATE SEQUENCE authors_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE authors_id_seq
OWNER TO postgres;
ALTER TABLE ONLY authors
ALTER COLUMN id SET DEFAULT nextval('authors_id_seq'::regclass);
It appears in the parser output:
$ sqlc parse schema.sql | grep _seq
Relname: (*string)(0xc000171010)((len=14) "authors_id_seq"),
Relname: (*string)(0xc000171460)((len=14) "authors_id_seq"),
Str: (string) (len=14) "authors_id_seq"