pgloader
pgloader copied to clipboard
Import from sqlite ignores generated columns
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
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