pgloader icon indicating copy to clipboard operation
pgloader copied to clipboard

Extra Underscore in Column Names When Using `snake_case` During Data-Only Migration from MSSQL to PostgreSQL

Open GentiSe opened this issue 7 months ago • 1 comments

Description

When using pgloader to perform a data-only migration from Microsoft SQL Server to PostgreSQL, and specifying a column naming convention such as snake_case, an additional underscore is incorrectly added to column names that already contain underscores.

Steps to Reproduce

  1. In SQL Server, have a table with a column named Column_Name.
  2. Use pgloader with data only migration enabled and with snake_case name transformation.
  3. Observe that pgloader attempts to write to a column named column__name (with a double underscore) instead of the correct column_name.

Expected Behavior

pgloader should map the column as it is from sql server to psql without adding an underscore if it has one.

Actual Behavior

pgloader transforms Column_Name into column__name, inserting an additional underscore, which causes a mismatch with the actual column names in the PostgreSQL schema and results in a migration failure.

Additional Notes

  • This issue only occurs during data-only migration when the PostgreSQL schema is pre-created.
  • The error does not occur when pgloader is allowed to create the schema (as it then matches its own column naming logic).

Wasn't able to find any command in the docs that handles this part.

GentiSe avatar May 15 '25 14:05 GentiSe

There is already a pull request about this issue. PR: https://github.com/dimitri/pgloader/pull/1652

GentiSe avatar May 15 '25 15:05 GentiSe