pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

Bug: varchar(n)[] length modifier silently dropped in dump

Open vytautas-karpavicius opened this issue 7 months ago • 0 comments

pgschema version: 1.9.0

Description

pgschema dump silently drops the length modifier from varchar(n)[] columns. The column is emitted as varchar[].

Steps to reproduce

# 0. Start PostgreSQL
docker run --rm -d --name pg15 -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 postgres:15

# 1. Create a database and load the schema
psql -h localhost -U postgres -c "CREATE DATABASE targetdb"
psql -h localhost -U postgres -d targetdb -c "
CREATE TABLE items (
    name  varchar(64),
    tags  varchar(128)[]
);"

# 2. Dump the schema
pgschema dump \
  --host localhost --port 5432 --user postgres \
  --db targetdb --sslmode disable

Expected result

CREATE TABLE IF NOT EXISTS items (
    name varchar(64),
    tags varchar(128)[]
);

Actual result

CREATE TABLE IF NOT EXISTS items (
    name varchar(64),
    tags varchar[]
);

The length modifier (128) is silently dropped. varchar(128) and varchar are not equivalent — varchar(128) enforces a max length at the database level.

vytautas-karpavicius avatar Apr 29 '26 13:04 vytautas-karpavicius