Skip to content

feat (conf file): add exclude/include parameter#78

Merged
pmpetit merged 3 commits into
mainfrom
feat/exclude_include
May 31, 2026
Merged

feat (conf file): add exclude/include parameter#78
pmpetit merged 3 commits into
mainfrom
feat/exclude_include

Conversation

@pmpetit
Copy link
Copy Markdown
Owner

@pmpetit pmpetit commented May 31, 2026

This pull request introduces significant improvements to the handling of primary keys, foreign keys, and type inference in the codebase, especially for multi-column primary keys and MongoDB-to-Postgres export logic. It also adds comprehensive tests to ensure correctness for these scenarios. The changes enhance support for tables with composite primary keys, improve the mapping of MongoDB IDs, and simplify type inference logic.

Primary key and foreign key handling:

  • Refactored TableNode and related logic in src/export.rs to support multiple primary key columns (pk_cols: Vec<String>) instead of a single pk_col, updating all related usages and row extraction logic to handle composite keys. [1] [2] [3] [4] [5]
  • Updated parse_sql in src/schema_diagram.rs to correctly parse and mark table-level (including multi-column) primary keys, removing the need for a fake primary key column. Added a helper function for parsing primary key columns and tests to verify correct marking of PK columns. [1] [2] [3]
  • Changed the internal representation of parent references in src/to_pg.rs to support multiple foreign key columns (parent_ref: Option<Vec<(String, String, String)>>), and updated child table creation logic to generate appropriate foreign key columns for both single and multi-column PKs. [1] [2] [3] [4] [5] [6]

MongoDB to Postgres export improvements:

  • Enhanced row extraction logic to correctly map MongoDB _id fields to the appropriate SQL columns, including handling of flattened object ID fields for composite PKs, and added tests to verify correct row extraction for both composite and scalar IDs. [1] [2]

Type inference and simplification:

  • Simplified type inference in src/to_pg.rs by removing the numeric_string_pg_type function, and ensuring that number fields are mapped to INTEGER, BIGINT, or DOUBLE PRECISION as appropriate, and mapping MongoDB ObjectId to TEXT instead of UUID. [1] [2] [3] [4]

Analyzer improvements:

  • Modified the analyzer in src/analyzer.rs so that empty arrays do not count as present for probability calculations, and added a test to verify this behavior. [1] [2]

These changes collectively improve the correctness, flexibility, and maintainability of the codebase, especially for complex database schemas and MongoDB-to-Postgres export scenarios.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 31, 2026

Preview build ready

Binaries for commit d8efa2c are available at:
https://github.com/pmpetit/mongo2pg/releases/tag/pr-78-preview

This release is updated on every push and deleted when the PR is closed.

@pmpetit pmpetit merged commit 84adfc9 into main May 31, 2026
3 checks passed
@pmpetit pmpetit deleted the feat/exclude_include branch May 31, 2026 15:46
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