sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Can't generate output if internal pg table is in use

Open tomee03 opened this issue 1 year ago • 0 comments

Version

1.27.0

What happened?

Hello,

I have one view with "pg_statio_all_tables" table and I can't generate code for this view. I don't know how I can continue with this view and sqlc.

Thank you

Relevant log output

# sqlc generate                                                                                                                                                                                                                                                                                                                                                         
# package db
# ../project/codelists/000010_view_columns.up.sql:1:1: relation "pg_statio_all_tables" does not exist

Database schema

CREATE VIEW "codelists"."view_columns" AS SELECT c.table_schema,
    c.table_name,
    c.column_name AS id,
    split_part(pgd.description, '@'::text, 1) AS name,
    split_part(pgd.description, '@'::text, 2)::boolean AS required,
    split_part(pgd.description, '@'::text, 3)::boolean AS hidden,
    split_part(pgd.description, '@'::text, 4)::boolean AS editable,
    split_part(pgd.description, '@'::text, 5) AS codelist
   FROM pg_statio_all_tables st
     JOIN pg_description pgd ON pgd.objoid = st.relid
     RIGHT JOIN information_schema.columns c ON pgd.objsubid = c.ordinal_position::integer AND c.table_schema::name = st.schemaname AND c.table_name::name = st.relname
  WHERE c.table_schema::name = 'codelists'::name;

SQL queries

-- name: GetColumns :many
SELECT id, name, required, hidden, editable, codelist FROM codelists.view_columns WHERE table_name = @table_name AND table_schema = @table_schema;

Configuration

version: "2"
sql:
  - engine: "postgresql"
    queries: "db/queries"
    schema: ["../project/codelists", "../project/stock", "../project/iam", "../project/clients", "../project/contracts"]
    gen:
      go:
        package: "db"
        sql_package: "pgx/v5"
        out: "db"
        emit_json_tags: true
        overrides:
          - go_type:
              import: "github.com/rs/xid"
              type:  "ID"
              package: "xid"
            db_type: "public.xid"

Playground URL

No response

What operating system are you using?

Linux, macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

tomee03 avatar Oct 03 '24 08:10 tomee03