Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tomee03 opened this issue Oct 3, 2024 · 0 comments
Open

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

tomee03 opened this issue Oct 3, 2024 · 0 comments
Labels

Comments

@tomee03
Copy link

tomee03 commented Oct 3, 2024

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 tomee03 added the bug Something isn't working label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant