Skip to content

Conversation

@michaelbromley
Copy link
Member

@michaelbromley michaelbromley commented Sep 19, 2025

This reverts commit 3c26cf1.

The PR #11114 fixes legitimate bugs, but unfortunately also introduces regressions for certain use-cases, as described in #11637, which was introduces in v0.3.26.

For now, we should revert the changes and then take the time to review how #11114 can be implemented & tested in such a way as it does not introduce this regression.

Description of change

Just a revert of the commit referenced above, nothing else.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • This pull request links relevant issues as Fixes #00000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change

Summary by CodeRabbit

  • New Features
    • Reliable generation of junction metadata for many-to-many relations, ensuring relations are consistently recognized even when custom tables share names.
  • Bug Fixes
    • Prevents missing relation metadata caused by previous deduplication logic with user-defined junction tables.
  • Tests
    • Removed obsolete functional tests tied to prior junction-table handling.
  • Chores
    • Internal clean-up aligned with updated junction metadata behavior.
  • Notes
    • No public API changes.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 19, 2025

Walkthrough

The metadata builder now always appends auto-generated junction entity metadata for many-to-many relations. Previously, it conditionally skipped appending when a non-junction entity shared the same table name. Associated functional tests and entity schema fixtures for the junction-table scenario were removed.

Changes

Cohort / File(s) Summary of edits
Metadata builder
src/metadata-builder/EntityMetadataBuilder.ts
Removed deduplication guard; junction entity metadata is unconditionally pushed during many-to-many junction creation. No API/signature changes.
Functional tests (junction table)
test/functional/entity-metadata/entity-metadata-builder.ts, test/functional/entity-metadata/entity/junction-table/entities.ts
Deleted functional test suite and related EntitySchema fixtures for user-defined junction table scenarios.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor App
    participant EMB as EntityMetadataBuilder
    participant Rel as Relation (Many-to-Many)
    participant JMF as Junction Metadata Factory

    App->>EMB: buildEntityMetadatas()
    EMB->>Rel: inspect relations
    alt Junction needed
        EMB->>JMF: create junction metadata
        note right of JMF: Auto-generated junction entity metadata
        JMF-->>EMB: junctionMetadata
        par Old flow (before)
            note over EMB: If user-defined non-junction entity<br/>shared the same table name, skip push
            EMB-->>EMB: Conditional append
        and New flow (now)
            note over EMB: Always append generated<br/>junction metadata
            EMB->>EMB: Unconditional append
        end
    else No junctions
        EMB-->>App: proceed
    end
    EMB-->>App: entityMetadatas (includes generated junctions)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

comp: relations, need review help, size-m

Suggested reviewers

  • sgarner
  • alumni
  • gioboa

Poem

A hop and a push—no second guess,
Junctions now join without duress.
Tests took a bow, the stage left clear,
Relations align, metadata near.
Thump-thump goes my codey heart—
Carrots for flows that never depart. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly states that this PR reverts PR #11114 and describes the behavior being reverted (not creating junction table metadata when it already exists), which matches the changeset that restores the prior behavior and removes the deduplication guard and related tests; it is concise and specific enough for a teammate scanning history to understand the primary change.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch revert-11114

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 19, 2025

typeorm-sql-js-example

npm i https://pkg.pr.new/typeorm/typeorm@11660

commit: 1b76755

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/metadata-builder/EntityMetadataBuilder.ts (1)

318-318: Add a brief comment explaining why duplicates are intentionally allowed again.

Helps future readers understand the revert context and avoid reintroducing the guard.

                         this.computeInverseProperties(
                             junctionEntityMetadata,
                             entityMetadatas,
                         )
+                        // Intentional revert of #11114: always append generated junction metadata.
+                        // Context: fixes regressions discussed in #11637; dedup will be reevaluated later.
                         entityMetadatas.push(junctionEntityMetadata)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a49f612 and 1b76755.

📒 Files selected for processing (3)
  • src/metadata-builder/EntityMetadataBuilder.ts (1 hunks)
  • test/functional/entity-metadata/entity-metadata-builder.ts (0 hunks)
  • test/functional/entity-metadata/entity/junction-table/entities.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • test/functional/entity-metadata/entity-metadata-builder.ts
  • test/functional/entity-metadata/entity/junction-table/entities.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Release preview build
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: tests-linux (20) / sap
  • GitHub Check: tests-linux (20) / oracle
  • GitHub Check: tests-linux (20) / mysql_mariadb_latest
  • GitHub Check: tests-linux (18) / sap
  • GitHub Check: tests-linux (20) / mssql
  • GitHub Check: tests-linux (18) / mysql_mariadb_latest
  • GitHub Check: tests-linux (18) / oracle
  • GitHub Check: tests-linux (18) / mssql
  • GitHub Check: tests-windows / sqlite
  • GitHub Check: tests-linux (20) / cockroachdb
🔇 Additional comments (1)
src/metadata-builder/EntityMetadataBuilder.ts (1)

318-318: Revert restores unconditional junction metadata push — code check OK; run cross‑driver tests

entityMetadatas.push(junctionEntityMetadata) is present at src/metadata-builder/EntityMetadataBuilder.ts:318. No other matches for dedup/duplicate/skip related to junction metadata were found in src. Run cross‑driver functional tests (many‑to‑many with synchronize on/off) to confirm #11637 is resolved and no duplicate-entity regressions surface.

@michaelbromley michaelbromley merged commit 34d8714 into master Sep 19, 2025
96 of 97 checks passed
@michaelbromley michaelbromley deleted the revert-11114 branch September 19, 2025 09:03
ThbltLmr pushed a commit to ThbltLmr/typeorm that referenced this pull request Dec 2, 2025
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.

5 participants