Skip to content

Running :copyfrom with a uuid causes ERROR: incorrect binary data format (SQLSTATE 22P03) with PGX #1507

Closed
@austincollinpena

Description

@austincollinpena

Version

1.12.0

What happened?

A bug happened!

Relevant log output

ERROR: incorrect binary data format (SQLSTATE 22P03)

Database schema

CREATE TABLE IF NOT EXISTS ad_check_results
(
    ad_check_results_id   uuid      DEFAULT gen_random_uuid(),
    query                 varchar(150) NOT NULL CHECK (query != ''),
    executed_at           TIMESTAMP DEFAULT now(),
    location              varchar(150) NOT NULL CHECK (location != ''),
    location_type         varchar(150),
    is_top                boolean      NOT NULL,
    position              int          NOT NULL,
    number_of_top_results int,
    total_number_of_ads   int,
    burst_run_number      int,
    headline              varchar(200) NOT NULL,
    description           varchar(300) NOT NULL,
    url                   TEXT,
    PRIMARY KEY (ad_check_results_id),
    ad_check_parent_id    uuid,
    CONSTRAINT fk_ad_check FOREIGN KEY (ad_check_parent_id) REFERENCES ad_check (ad_check_id) ON DELETE SET NULL
)

SQL queries

-- name: BulkInsertAdResults :copyfrom
INSERT INTO ad_check_results (query, location, location_type, is_top, position,
                              number_of_top_results, total_number_of_ads, headline, description, url,
                              ad_check_parent_id)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);

Configuration

version: 1
packages:
  - name: db_access
    path: "ad_intelligence_project/db_access"
    queries: ["./ad_intelligence_project/biz_logic/organization/org-sql", "./ad_intelligence_project/biz_logic/ad_intelligence/sql"]
    schema: "./go_common/db/a_db/migrations"
    sql_package: pgx/v4
    emit_json_tags: true
overrides:
  - column: "ad_check.country_to_check"
    go_type: "database/sql.NullString"
  - column: "ad_check.utc_times_of_checks"
    go_type: "github.com/lib/pq.StringArray"

Playground URL

https://play.sqlc.dev/p/2d26c7887908446358ff23c10defa67e2a2d3a7c4f34e2b1a0e686560420659e

What operating system are you using?

Windows

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions