dimitri / pgloader

Migrate to PostgreSQL in a single command!

Home Page:http://pgloader.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect default cast from MSSQL `int` (auto-increment) to PG `bigserial`

nathanael-ruf opened this issue · comments

int is 4 bytes in mssql: https://learn.microsoft.com/en-us/sql/t-sql/data-types/int-bigint-smallint-and-tinyint-transact-sql?view=sql-server-ver16
bigserial is 8 bytes: https://www.postgresql.org/docs/current/datatype-numeric.html

Expected: pgloader converts to serial (4 bytes).

Besides just more space this has implications for node applications using the pg library which returns strings instead of numbers because numbers in js can't represent full 64bit integers.

Location in the code:

(:source (:type "int" :auto-increment t)
:target (:type "bigserial" :drop-default t))

(related: #1586. I only found this issue after applying the fix of #1586 on a fork)