Open
Description
Version
1.16.0
What happened?
Postgres copyfrom query in a table which has a column with Enum type fails. I am using pgx5.
Relevant log output
ERROR: COPY from stdin failed: unable to encode "ENUM_VALUE" into binary format for unknown type (OID 16393): cannot find encode plan
Database schema
CREATE TABLE violation (
slug VARCHAR(64) PRIMARY KEY UNIQUE,
parent VARCHAR(64),
FOREIGN KEY (parent) REFERENCES violation(slug) ON DELETE SET NULL
);
CREATE TYPE reference_types AS ENUM (
'DEFAULT',
'ENUM_VALUE',
'OTHER_VALUE'
);
CREATE TABLE user_violation (
id serial PRIMARY KEY,
violation_slug VARCHAR(64) NOT NULL,
FOREIGN KEY (violation_slug) REFERENCES violation(slug) ON DELETE SET NULL,
reference_type reference_types NOT NULL,
);
SQL queries
-- name: BulkInsertUserViolations :copyfrom
INSERT INTO user_violation (
violation_slug,
reference_type
) VALUES (
$1,
$2
);
Configuration
version: "1"
packages:
- name: "violation"
path: "../internal/violation"
queries: "../internal/violation/queries"
schema: "../internal/violation/migrations"
engine: "postgresql"
sql_package: "pgx/v5"
emit_json_tags: false
emit_prepared_queries: false
emit_interface: true
emit_exact_table_names: false
overrides:
- go_type: "github.com/jackc/pgx/v5/pgtype.UUID"
db_type: "uuid"
Playground URL
https://play.sqlc.dev/p/70883aaa9d4b68218cca526275348874560f43aa01ffa362d8364516f5104c16
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go