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

pg_enum system catalog not available to sqlc #1170

Closed
rhodee opened this issue Sep 9, 2021 · 3 comments
Closed

pg_enum system catalog not available to sqlc #1170

rhodee opened this issue Sep 9, 2021 · 3 comments
Labels
📚 postgresql bug Something isn't working

Comments

@rhodee
Copy link

rhodee commented Sep 9, 2021

Version

1.9.0

What happened?

Expected sqlc generate to create a function to be used in Go code. This is an alternative attempt to solve the issue found here: #1126.

Relevant log output

sql/queries/lot_attributes.sql:133:1: relation "pg_enum" does not exist

Database schema

-- migrate:up
CREATE TYPE lot_destination_status AS ENUM ('origin', 'in_transit', 'spot')

SQL queries

-- name: LotDestinationStatus :many
SELECT
  enum.enumlabel AS value
FROM
  pg_enum AS enum
  JOIN pg_type AS type ON (type.oid = enum.enumtypid)
WHERE
  type.typname = 'lot_destination_status'
GROUP BY
  enum.enumlabel,
  type.typname;

Configuration

version: "1"
packages:
- name: "store"
  path: "store"
  queries: "./sql/queries"
  schema: "./sql/migrations"
  engine: "postgresql"
  emit_json_tags: true
  emit_prepared_queries: true
  emit_interface: false
  emit_exact_table_names: false
  emit_empty_slices: false

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@rhodee rhodee added bug Something isn't working triage New issues that hasn't been reviewed labels Sep 9, 2021
@kyleconroy kyleconroy added bug Something isn't working 📚 postgresql and removed bug Something isn't working triage New issues that hasn't been reviewed labels Sep 9, 2021
@kyleconroy
Copy link
Collaborator

We don't have support yet for the PostgreSQL system catalogs. I opened a new issues to track implementation here: #1171

@kyleconroy
Copy link
Collaborator

As a work around, you can define the system catalogs that you need.

https://play.sqlc.dev/p/ffdcb40a5eeb39f753c53ce4c35ef35f16bb1745fea84b5283a2fcea56891e74

This probably won't get what you want, as sqlc will return interface{} for certain internal types.

@rhodee
Copy link
Author

rhodee commented Sep 12, 2021

Thanks @kyleconroy

@rhodee rhodee closed this as completed Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 postgresql bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants