Skip to content

feat: keep schema, table and column comments - #39

Open
TheCrab13 wants to merge 1 commit into
mainfrom
feat/db2sql-keep-comments/ENG-1344
Open

TheCrab13 wants to merge 1 commit into
mainfrom
feat/db2sql-keep-comments/ENG-1344

Conversation

@TheCrab13

Copy link
Copy Markdown
Contributor

Summary

The comments of the source schemas, tables and columns were lost. They are now copied to the target, in dump and migrate modes.

Source Schema Table Column
PostgreSQL yes yes yes
MSSQL (MS_Description) yes yes yes
MySQL / MariaDB no yes yes
Oracle n/a yes yes
SQLite n/a n/a n/a

The PostgreSQL target gets COMMENT ON. The MSSQL target gets sp_addextendedproperty, or sp_updateextendedproperty for a schema that already has a description (dbo).

Type of change

  • Feature (feat:)

How was this tested?

  • pytest tests/unit tests/cli: 641 passed, 12 new tests
  • lint-imports: 2 contracts kept
  • black, isort, flake8, pylint 10.00/10. mypy reports the 9 errors that main already has in the SQLite reader.
  • tests/functional: not run, no Docker

Manual check on PostgreSQL 15: dump, psql -f, then migrate. The comments are in the target. The MSSQL output was not run on a server.

Notes for the reviewer

  • The default comment of public (standard public schema) is not copied: only the owner of a schema can comment on it.
  • With schema_mapping, when several source schemas map to one target, the first comment wins.
  • No comment is emitted with --on-existing truncate.

Read the comments of the source and emit them on the target: COMMENT ON for PostgreSQL, the MS_Description property for MSSQL.
@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.24812% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
db2sql/infrastructure/persistence/oracle/reader.py 95.65% 1 Missing ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #39      +/-   ##
==========================================
+ Coverage   92.24%   92.50%   +0.25%     
==========================================
  Files          79       79              
  Lines        3225     3347     +122     
==========================================
+ Hits         2975     3096     +121     
- Misses        250      251       +1     
Files with missing lines Coverage Δ
db2sql/domain/model/column.py 100.00% <100.00%> (ø)
db2sql/domain/model/schema.py 100.00% <100.00%> (ø)
db2sql/domain/model/table.py 100.00% <100.00%> (ø)
db2sql/infrastructure/emit/mssql/emitter.py 98.75% <100.00%> (+0.21%) ⬆️
db2sql/infrastructure/emit/postgres/emitter.py 99.29% <100.00%> (+0.05%) ⬆️
db2sql/infrastructure/persistence/mssql/reader.py 98.47% <100.00%> (+0.25%) ⬆️
db2sql/infrastructure/persistence/mysql/reader.py 96.73% <100.00%> (ø)
...2sql/infrastructure/persistence/postgres/reader.py 98.09% <100.00%> (+0.44%) ⬆️
db2sql/infrastructure/persistence/oracle/reader.py 97.67% <95.65%> (-0.25%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant