pgloader icon indicating copy to clipboard operation
pgloader copied to clipboard

Import from sqlite ignores generated columns

Open c-w opened this issue 3 months ago • 1 comments

pgloader 3.6.7~devel skips sqlite generated columns when importing to postgres. I'd expect this to translate to postgres generated columns.

Minimal repro

Step 1: create a sqlite database with a generated column.

sqlite3 foo.db 'create table foo(id integer, gen integer generated always as (id+1));'

Step 2: run pgloader

pgloader --with 'create no indexes' --with 'no foreign keys' --with 'schema only' \
  sqlite://./foo.db "pgsql://${PGUSER}:${PGPASSWORD}@${PGHOST}/${PGDATABASE}"

Step 3: inspect postgres schema

psql -c '\d+ foo'

Actual: schema in postgres doesn't include generated column

                                          Table "public.foo"
 Column |  Type  | Collation | Nullable | Default | Storage | Compression | Stats target | Description 
--------+--------+-----------+----------+---------+---------+-------------+--------------+-------------
 id     | bigint |           |          |         | plain   |             |              | 
Access method: heap

Expected: schema in postgres includes generated column

c-w avatar Oct 06 '25 10:10 c-w

I think you should be able to fix this with casting rules right? https://pgloader.readthedocs.io/en/latest/ref/sqlite.html#default-sqlite-casting-rules

coreyman avatar Oct 21 '25 04:10 coreyman