dimitri / pgloader

Migrate to PostgreSQL in a single command!
http://pgloader.io
Other
5.45k stars 548 forks source link

Fix "reset sequences" crash on tables with case sensitive column names #1509

Open codereverser opened 1 year ago

codereverser commented 1 year ago

On case sensitive migrations (i.e. with "quote identifiers"), reset sequences fail with the following error.

Database error 42703: column ""<columnName>"" of relation "<table>" does not exist

This is due to invalid parameters being passed to pg_get_serial_sequence function introduced in e32066d35a03df3b386189d5c4e9dcd11805ee03

for example, on a mysql table with following definition

CREATE TABLE botLog(
    `logID` bigint(20) NOT NULL AUTO_INCREMENT, 
    `message` varchar(255), 
    PRIMARY KEY (`logID`)
);
SELECT pg_get_serial_sequence(quote_ident('public') || '.' || quote_ident('botLog'), quote_ident('logID'));
ERROR:  column ""logID"" of relation "botLog" does not exist

throws the same error, but the following works

SELECT pg_get_serial_sequence(quote_ident('public') || '.' || quote_ident('botLog'), 'logID');
  pg_get_serial_sequence
---------------------------
 public."botLog_logID_seq"

ref: https://github.com/dimitri/pgloader/issues/425

Asher-JH commented 1 month ago

Is this something that can be merged in soon? facing this issue