Skip to content

refactor!: rename connection to dataSource in the metadata classes#12249

Merged
alumni merged 1 commit intomasterfrom
refactor/connection-to-data-source-metadata
Mar 23, 2026
Merged

refactor!: rename connection to dataSource in the metadata classes#12249
alumni merged 1 commit intomasterfrom
refactor/connection-to-data-source-metadata

Conversation

@alumni
Copy link
Copy Markdown
Collaborator

@alumni alumni commented Mar 20, 2026

Description of change

Step 4/4 in renaming connection to dataSource.

The rename is done for the metadata classes.

Closes #12082.

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 tests validating the change (tests/**.test.ts)
  • Documentation has been updated to reflect this change (docs/docs/**.md)

@alumni alumni changed the base branch from master to refactor/connection-to-data-source-events March 20, 2026 10:40
@qodo-free-for-open-source-projects
Copy link
Copy Markdown

Review Summary by Qodo

Refactor: Rename connection to dataSource in metadata classes and related components

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Comprehensive refactoring renaming connection to dataSource across metadata classes and
  related components (Step 4/4)
• Updated 50+ driver query runner classes to use dataSource instead of connection (SqlServer,
  CockroachDB, Postgres, Oracle, MySQL, MongoDB, SAP, Spanner, etc.)
• Renamed connection property to dataSource in core classes with deprecated getters for backward
  compatibility:
  - EntityMetadata, EntityManager, MongoEntityManager
  - QueryBuilder, SelectQueryBuilder, InsertQueryBuilder, UpdateQueryBuilder,
  DeleteQueryBuilder, SoftDeleteQueryBuilder
  - BaseQueryRunner, all driver classes
• Created new BaseEvent interface to consolidate common event properties and reduce duplication
  across subscriber events
• Refactored subscriber events (InsertEvent, UpdateEvent, RemoveEvent, LoadEvent,
  TransactionStartEvent, TransactionCommitEvent, TransactionRollbackEvent) to extend BaseEvent
• Updated Broadcaster to maintain backward compatibility by passing both dataSource and
  connection properties in subscriber events
• Removed connection parameter from ColumnMetadata constructor and updated metadata builders
  accordingly
• Updated test files and migrations to use new dataSource parameter naming
• Maintained backward compatibility throughout with deprecated getters returning dataSource value
Diagram
flowchart LR
  A["connection property"] -->|"rename to"| B["dataSource property"]
  B -->|"add deprecated getter"| C["connection getter"]
  D["Metadata Classes<br/>EntityMetadata<br/>ColumnMetadata"] -->|"updated"| B
  E["Query Builders<br/>SelectQueryBuilder<br/>InsertQueryBuilder"] -->|"updated"| B
  F["Query Runners<br/>BaseQueryRunner<br/>Driver Runners"] -->|"updated"| B
  G["Subscriber Events<br/>InsertEvent<br/>UpdateEvent"] -->|"extend"| H["BaseEvent<br/>with dataSource"]
  I["Broadcaster"] -->|"maintains compatibility"| J["passes both<br/>dataSource & connection"]
Loading

Grey Divider

File Changes

1. src/driver/sqlserver/SqlServerQueryRunner.ts Refactoring +67/-67

Rename connection to dataSource in SqlServer query runner

• Renamed this.connection to this.dataSource throughout the file (60+ occurrences)
• Updated references to this.driver.connection to this.driver.dataSource
• Updated all namingStrategy calls to use this.dataSource instead of this.connection
• Updated logger calls to use this.dataSource.logger instead of this.connection.logger

src/driver/sqlserver/SqlServerQueryRunner.ts


2. src/driver/cockroachdb/CockroachQueryRunner.ts Refactoring +53/-53

Rename connection to dataSource in CockroachDB query runner

• Renamed this.connection to this.dataSource throughout the file (50+ occurrences)
• Updated references to this.driver.connection to this.driver.dataSource
• Updated all namingStrategy calls to use this.dataSource instead of this.connection
• Updated logger and driver method calls to use this.dataSource

src/driver/cockroachdb/CockroachQueryRunner.ts


3. src/driver/postgres/PostgresQueryRunner.ts Refactoring +53/-53

Rename connection to dataSource in Postgres query runner

• Renamed this.connection to this.dataSource throughout the file (50+ occurrences)
• Updated references to this.driver.connection to this.driver.dataSource
• Updated all namingStrategy calls to use this.dataSource instead of this.connection
• Updated logger and driver method calls to use this.dataSource

src/driver/postgres/PostgresQueryRunner.ts


View more (90)
4. src/driver/oracle/OracleQueryRunner.ts Refactoring +51/-51

Rename connection to dataSource in Oracle query runner

• Renamed this.connection to this.dataSource throughout the file (40+ occurrences)
• Updated references to this.driver.connection to this.driver.dataSource
• Updated all namingStrategy calls to use this.dataSource instead of this.connection
• Updated logger and driver method calls to use this.dataSource

src/driver/oracle/OracleQueryRunner.ts


5. src/query-builder/InsertQueryBuilder.ts Refactoring +101/-101

Rename connection to dataSource in Insert query builder

• Renamed this.connection to this.dataSource throughout the file (70+ occurrences)
• Updated driver option checks to use this.dataSource.driver.options.type
• Updated driver utility calls to use this.dataSource.driver
• Updated all driver method calls to reference this.dataSource.driver

src/query-builder/InsertQueryBuilder.ts


6. src/entity-manager/EntityManager.ts Refactoring +57/-49

Rename connection to dataSource in EntityManager with deprecation

• Renamed property connection to dataSource in the class definition
• Added deprecated getter connection that returns this.dataSource for backward compatibility
• Updated constructor parameter from connection to dataSource
• Updated all internal references from this.connection to this.dataSource (50+ occurrences)

src/entity-manager/EntityManager.ts


7. src/driver/spanner/SpannerQueryRunner.ts Refactoring +25/-25

Rename connection to dataSource in Spanner query runner

• Renamed this.connection to this.dataSource throughout the file (20+ occurrences)
• Updated references to this.driver.connection to this.driver.dataSource
• Updated all namingStrategy calls to use this.dataSource instead of this.connection
• Updated logger and driver method calls to use this.dataSource

src/driver/spanner/SpannerQueryRunner.ts


8. src/metadata-builder/ClosureJunctionEntityMetadataBuilder.ts Refactoring +1/-4

Rename connection to dataSource in metadata builder

• Renamed constructor parameter from connection to dataSource in EntityMetadata initialization

src/metadata-builder/ClosureJunctionEntityMetadataBuilder.ts


9. src/driver/nativescript/NativescriptQueryRunner.ts Refactoring +2/-2

Rename connection to dataSource in Nativescript query runner

• Renamed this.connection to this.dataSource in constructor
• Updated local variable reference from this.driver.connection to this.driver.dataSource

src/driver/nativescript/NativescriptQueryRunner.ts


10. src/driver/sap/SapQueryRunner.ts Refactoring +47/-47

Rename connection to dataSource in SAP query runner

• Renamed this.connection to this.dataSource throughout the file (1 occurrence in constructor)
• Updated all references from this.driver.connection to this.driver.dataSource for logger and
 naming strategy calls (40+ occurrences)
• Updated references to this.connection.namingStrategy and this.connection.entityMetadatas to
 use this.dataSource instead

src/driver/sap/SapQueryRunner.ts


11. src/entity-manager/MongoEntityManager.ts Refactoring +50/-50

Rename connection to dataSource in Mongo entity manager

• Updated constructor parameter from connection to dataSource
• Renamed property access from this.connection to this.dataSource throughout the file (50+
 occurrences)
• Updated getter for mongoQueryRunner to use this.dataSource.driver instead of
 this.connection.driver

src/entity-manager/MongoEntityManager.ts


12. src/query-builder/SelectQueryBuilder.ts Refactoring +66/-66

Rename connection to dataSource in select query builder

• Renamed this.connection to this.dataSource throughout the file (80+ occurrences)
• Updated all driver, options, and metadata access to use this.dataSource instead of
 this.connection
• Updated cache and query result cache references to use this.dataSource

src/query-builder/SelectQueryBuilder.ts


13. src/driver/mysql/MysqlQueryRunner.ts Refactoring +29/-29

Rename connection to dataSource in MySQL query runner

• Renamed this.connection to this.dataSource in constructor (1 occurrence)
• Updated all references from this.driver.connection to this.driver.dataSource for logger and
 naming strategy calls (30+ occurrences)
• Updated references to this.connection.namingStrategy and this.connection.entityMetadatas to
 use this.dataSource

src/driver/mysql/MysqlQueryRunner.ts


14. src/subscriber/Broadcaster.ts Refactoring +75/-58

Rename connection to dataSource in broadcaster with backward compatibility

• Renamed this.queryRunner.connection to this.queryRunner.dataSource for subscriber access (20+
 occurrences)
• Added backward compatibility by passing both dataSource and connection properties in
 subscriber event objects
• Updated all subscriber event broadcasts to use this.queryRunner.dataSource instead of
 this.queryRunner.connection

src/subscriber/Broadcaster.ts


15. src/driver/sqlite-abstract/AbstractSqliteQueryRunner.ts Refactoring +23/-23

Rename connection to dataSource in abstract SQLite query runner

• Renamed this.connection to this.dataSource throughout the file (50+ occurrences)
• Updated all naming strategy and driver references to use this.dataSource instead of
 this.connection
• Updated view expression calls to pass this.dataSource instead of this.connection

src/driver/sqlite-abstract/AbstractSqliteQueryRunner.ts


16. src/driver/postgres/PostgresDriver.ts Refactoring +33/-24

Rename connection to dataSource in Postgres driver with deprecation

• Renamed property connection to dataSource with getter for backward compatibility
• Updated constructor parameter from connection to dataSource
• Updated all internal references from this.connection to this.dataSource (15+ occurrences)
• Moved ReturningType import from Driver to separate types file

src/driver/postgres/PostgresDriver.ts


17. src/driver/aurora-mysql/AuroraMysqlQueryRunner.ts Refactoring +19/-19

Rename connection to dataSource in Aurora MySQL query runner

• Renamed this.connection to this.dataSource in constructor (1 occurrence)
• Updated all references from this.driver.connection to this.driver.dataSource for naming
 strategy calls (20+ occurrences)
• Updated view expression calls to pass this.dataSource instead of this.connection

src/driver/aurora-mysql/AuroraMysqlQueryRunner.ts


18. src/driver/mongodb/MongoQueryRunner.ts Refactoring +54/-87

Rename connection to dataSource in MongoDB query runner with cleanup

• Reorganized imports alphabetically and by type
• Renamed connection property to dataSource with getter for backward compatibility
• Updated constructor parameter from connection to dataSource
• Updated all internal references from this.connection to this.dataSource (5+ occurrences)
• Removed commented-out legacy insert, update, and delete methods

src/driver/mongodb/MongoQueryRunner.ts


19. src/query-builder/QueryBuilder.ts Refactoring +34/-26

Rename connection to dataSource in query builder with deprecation

• Renamed connection property to dataSource with getter for backward compatibility
• Updated constructor to use dataSource parameter instead of connection
• Updated all references from this.connection to this.dataSource throughout the file (40+
 occurrences)
• Moved ReturningType import from Driver to separate types file

src/query-builder/QueryBuilder.ts


20. src/query-runner/BaseQueryRunner.ts Refactoring +41/-33

Rename connection to dataSource in base query runner with deprecation

• Renamed connection property to dataSource with getter for backward compatibility
• Updated all references from this.connection to this.dataSource throughout the file (50+
 occurrences)
• Updated all driver, metadata, and naming strategy access to use this.dataSource

src/query-runner/BaseQueryRunner.ts


21. src/query-builder/UpdateQueryBuilder.ts Refactoring +24/-24

Rename connection to dataSource in update query builder

• Updated all references from this.connection to this.dataSource throughout the file (30+
 occurrences)
• Updated driver type checks and method calls to use this.dataSource.driver instead of
 this.connection.driver

src/query-builder/UpdateQueryBuilder.ts


22. src/find-options/FindOptionsUtils.ts Refactoring +2/-2

Rename connection to dataSource in find options utils

• Updated qb.connection.driver references to qb.dataSource.driver (2 occurrences)
• Changed alias generation to use the new dataSource property

src/find-options/FindOptionsUtils.ts


23. src/driver/aurora-mysql/AuroraMysqlDriver.ts Refactoring +21/-22

Rename connection to dataSource in AuroraMysqlDriver

• Renamed connection property to dataSource with deprecated getter for backward compatibility
• Removed unused UnsignedColumnType import
• Removed unsignedColumnTypes property from driver
• Updated constructor parameter and all internal references from connection to dataSource

src/driver/aurora-mysql/AuroraMysqlDriver.ts


24. src/driver/sqlserver/SqlServerDriver.ts Refactoring +20/-11

Rename connection to dataSource in SqlServerDriver

• Renamed connection property to dataSource with deprecated getter for backward compatibility
• Moved ReturningType import to separate types file
• Updated constructor parameter and all internal references from connection to dataSource

src/driver/sqlserver/SqlServerDriver.ts


25. src/driver/aurora-postgres/AuroraPostgresDriver.ts Refactoring +9/-16

Rename connection to dataSource in AuroraPostgresDriver

• Removed explicit connection property declaration (inherited from parent)
• Updated constructor parameter from connection to dataSource
• Updated all internal references from connection to dataSource
• Added return type annotation to createQueryRunner method

src/driver/aurora-postgres/AuroraPostgresDriver.ts


26. src/driver/mysql/MysqlDriver.ts Refactoring +19/-22

Rename connection to dataSource in MysqlDriver

• Renamed connection property to dataSource with deprecated getter for backward compatibility
• Removed unused UnsignedColumnType import and unsignedColumnTypes property
• Moved ReturningType import to separate types file
• Updated constructor parameter and all internal references from connection to dataSource

src/driver/mysql/MysqlDriver.ts


27. src/metadata/ColumnMetadata.ts Refactoring +18/-29

Remove connection parameter from ColumnMetadata constructor

• Removed connection parameter from constructor options
• Extracted driver reference from entityMetadata.dataSource.driver for cleaner code
• Updated all references from options.connection.driver to driver variable
• Simplified property assignments and formatting

src/metadata/ColumnMetadata.ts


28. src/driver/cockroachdb/CockroachDriver.ts Refactoring +20/-11

Rename connection to dataSource in CockroachDriver

• Renamed connection property to dataSource (readonly) with deprecated getter
• Moved ReturningType import to separate types file
• Updated constructor parameter and all internal references from connection to dataSource

src/driver/cockroachdb/CockroachDriver.ts


29. src/driver/cordova/CordovaQueryRunner.ts Refactoring +4/-39

Update connection references to dataSource in CordovaQueryRunner

• Updated property assignment from driver.connection to driver.dataSource
• Updated all logger calls from driver.connection.logger to driver.dataSource.logger

src/driver/cordova/CordovaQueryRunner.ts


30. src/metadata/EntityMetadata.ts Refactoring +24/-16

Rename connection to dataSource in EntityMetadata

• Renamed connection property to dataSource with deprecated getter for backward compatibility
• Updated constructor parameter from connection to dataSource
• Updated all internal references from connection to dataSource throughout the class

src/metadata/EntityMetadata.ts


31. src/metadata-builder/EntityMetadataBuilder.ts Refactoring +4/-10

Update metadata builders to use dataSource parameter

• Updated EntityMetadata constructor call to use dataSource parameter instead of connection
• Removed connection parameter from ColumnMetadata constructor calls
• Simplified object literal syntax in constructor calls

src/metadata-builder/EntityMetadataBuilder.ts


32. src/persistence/tree/ClosureSubjectExecutor.ts Refactoring +9/-9

Update connection references to dataSource in ClosureSubjectExecutor

• Updated all references from queryRunner.connection to queryRunner.dataSource
• Updated driver method calls to use dataSource property

src/persistence/tree/ClosureSubjectExecutor.ts


33. src/driver/spanner/SpannerDriver.ts Refactoring +17/-8

Rename connection to dataSource in SpannerDriver

• Renamed connection property to dataSource with deprecated getter for backward compatibility
• Moved ReturningType import to separate types file
• Updated constructor parameter and all internal references from connection to dataSource

src/driver/spanner/SpannerDriver.ts


34. src/driver/better-sqlite3/BetterSqlite3QueryRunner.ts Refactoring +7/-7

Update connection references to dataSource in BetterSqlite3QueryRunner

• Reorganized import statements alphabetically
• Updated property assignment from driver.connection to driver.dataSource
• Updated logger calls from driver.connection.logger to driver.dataSource.logger

src/driver/better-sqlite3/BetterSqlite3QueryRunner.ts


35. src/query-builder/ReturningResultsEntityUpdator.ts Refactoring +8/-8

Update connection references to dataSource in ReturningResultsEntityUpdator

• Updated all references from queryRunner.connection to queryRunner.dataSource
• Updated driver method calls to use dataSource property

src/query-builder/ReturningResultsEntityUpdator.ts


36. src/persistence/SubjectExecutor.ts Refactoring +9/-9

Update connection references to dataSource in SubjectExecutor

• Updated all references from queryRunner.connection to queryRunner.dataSource
• Updated driver method calls to use dataSource property

src/persistence/SubjectExecutor.ts


37. src/driver/Driver.ts Refactoring +17/-18

Reorganize Driver interface imports and exports

• Reorganized import statements alphabetically
• Moved ReturningType export to separate types file
• Updated JSDoc comment from "Connection options" to "Data Source options"

src/driver/Driver.ts


38. src/driver/oracle/OracleDriver.ts Refactoring +6/-5

Rename connection to dataSource in OracleDriver

• Renamed connection property to dataSource
• Moved ReturningType import to separate types file
• Updated constructor and all internal references from connection to dataSource

src/driver/oracle/OracleDriver.ts


39. src/driver/sap/SapDriver.ts Refactoring +16/-8

Rename connection to dataSource in SapDriver

• Renamed connection property to dataSource with deprecated getter for backward compatibility
• Updated constructor parameter and all internal references from connection to dataSource

src/driver/sap/SapDriver.ts


40. src/persistence/tree/NestedSetSubjectExecutor.ts Refactoring +6/-6

Update connection references to dataSource in NestedSetSubjectExecutor

• Updated all references from queryRunner.connection to queryRunner.dataSource
• Updated driver method calls to use dataSource property

src/persistence/tree/NestedSetSubjectExecutor.ts


41. src/driver/capacitor/CapacitorQueryRunner.ts Refactoring +7/-7

Update connection references to dataSource in CapacitorQueryRunner

• Reorganized import statements alphabetically
• Updated property assignment from driver.connection to driver.dataSource
• Updated logger calls from driver.connection.logger to driver.dataSource.logger

src/driver/capacitor/CapacitorQueryRunner.ts


42. src/driver/react-native/ReactNativeDriver.ts Refactoring +15/-7

Rename connection to dataSource in ReactNativeDriver

• Renamed connection property to dataSource with deprecated getter for backward compatibility
• Updated constructor parameter and all internal references from connection to dataSource

src/driver/react-native/ReactNativeDriver.ts


43. src/driver/sqlite-abstract/AbstractSqliteDriver.ts Refactoring +15/-7

Rename connection to dataSource in AbstractSqliteDriver

• Renamed connection property to dataSource with deprecated getter for backward compatibility
• Updated constructor parameter and all internal references from connection to dataSource

src/driver/sqlite-abstract/AbstractSqliteDriver.ts


44. src/driver/mongodb/MongoDriver.ts Refactoring +7/-7

Rename connection to dataSource in MongoDriver

• Renamed connection property to dataSource in constructor
• Updated all internal references from connection to dataSource

src/driver/mongodb/MongoDriver.ts


45. src/driver/expo/ExpoQueryRunner.ts Refactoring +4/-4

Update connection references to dataSource in ExpoQueryRunner

• Updated property assignment from driver.connection to driver.dataSource
• Updated logger calls from driver.connection.logger to driver.dataSource.logger

src/driver/expo/ExpoQueryRunner.ts


46. src/repository/TreeRepository.ts Refactoring +6/-6

Update connection references to dataSource in TreeRepository

• Updated all references from manager.connection to manager.dataSource
• Updated driver method calls to use dataSource property

src/repository/TreeRepository.ts


47. src/driver/react-native/ReactNativeQueryRunner.ts Refactoring +4/-4

Update connection references to dataSource in ReactNativeQueryRunner

• Updated property assignment from driver.connection to driver.dataSource
• Updated logger calls from driver.connection.logger to driver.dataSource.logger

src/driver/react-native/ReactNativeQueryRunner.ts


48. src/driver/sqljs/SqljsQueryRunner.ts Refactoring +4/-4

Update connection references to dataSource in SqljsQueryRunner

• Updated property assignment from driver.connection to driver.dataSource
• Updated logger calls from driver.connection.logger to driver.dataSource.logger

src/driver/sqljs/SqljsQueryRunner.ts


49. src/driver/better-sqlite3/BetterSqlite3Driver.ts Refactoring +6/-8

Update connection references and Node.js imports in BetterSqlite3Driver

• Updated import statements to use node: prefix for Node.js built-in modules
• Updated constructor parameter from connection to dataSource
• Updated query call from connection.query to dataSource.query

src/driver/better-sqlite3/BetterSqlite3Driver.ts


50. src/driver/sqljs/SqljsDriver.ts Refactoring +4/-4

Update connection references to dataSource in SqljsDriver

• Updated constructor parameter from connection to dataSource
• Updated logger calls from connection.logger to dataSource.logger

src/driver/sqljs/SqljsDriver.ts


51. src/subscriber/event/UpdateEvent.ts Refactoring +4/-23

Refactor UpdateEvent to extend BaseEvent

• Refactored to extend BaseEvent interface instead of duplicating properties
• Removed duplicate connection, queryRunner, and manager property definitions

src/subscriber/event/UpdateEvent.ts


52. test/github-issues/1623/issue-1623.test.ts 🧪 Tests +6/-7

Update test to use dataSource parameter

• Renamed parameter from connection to dataSource in test callback
• Removed connection parameter from ColumnMetadata constructor call
• Updated all references from connection to dataSource

test/github-issues/1623/issue-1623.test.ts


53. src/metadata-builder/JunctionEntityMetadataBuilder.ts Refactoring +2/-4

Update junction metadata builder to use dataSource parameter

• Updated EntityMetadata constructor call to use dataSource parameter
• Removed connection parameter from ColumnMetadata constructor calls
• Simplified object literal syntax in constructor calls

src/metadata-builder/JunctionEntityMetadataBuilder.ts


54. src/query-builder/SoftDeleteQueryBuilder.ts Refactoring +3/-3

Update connection references to dataSource in SoftDeleteQueryBuilder

• Updated all references from connection to dataSource
• Updated driver method calls to use dataSource property

src/query-builder/SoftDeleteQueryBuilder.ts


55. src/subscriber/event/InsertEvent.ts Refactoring +3/-22

Refactor InsertEvent to extend BaseEvent

• Refactored to extend BaseEvent interface instead of duplicating properties
• Removed duplicate connection, queryRunner, and manager property definitions

src/subscriber/event/InsertEvent.ts


56. src/subscriber/event/RemoveEvent.ts Refactoring +2/-21

Refactor RemoveEvent to extend BaseEvent

• Refactored to extend BaseEvent interface instead of duplicating properties
• Removed duplicate connection, queryRunner, and manager property definitions

src/subscriber/event/RemoveEvent.ts


57. src/entity-manager/EntityManagerFactory.ts Refactoring +8/-7

Update EntityManagerFactory to use dataSource parameter

• Updated parameter name from connection to dataSource in JSDoc and method signature
• Updated all internal references from connection to dataSource
• Added return type documentation in JSDoc

src/entity-manager/EntityManagerFactory.ts


58. test/github-issues/4697/migration/1567689639607-MergeConfigs.ts 🧪 Tests +6/-6

Update migration to use manager instead of connection

• Updated migration method parameters from connection to manager
• Updated all repository access from connection.getMongoRepository to manager.getMongoRepository

test/github-issues/4697/migration/1567689639607-MergeConfigs.ts


59. src/subscriber/event/BaseEvent.ts ✨ Enhancement +31/-0

Create BaseEvent interface for event inheritance

• Created new base event interface with common properties
• Includes dataSource property with deprecated connection getter
• Includes queryRunner and manager properties

src/subscriber/event/BaseEvent.ts


60. src/query-builder/DeleteQueryBuilder.ts Refactoring +3/-3

Update connection references to dataSource in DeleteQueryBuilder

• Updated all references from connection to dataSource
• Updated driver method calls to use dataSource property

src/query-builder/DeleteQueryBuilder.ts


61. src/subscriber/event/LoadEvent.ts Refactoring +2/-21

Refactor LoadEvent to extend BaseEvent

• Refactored to extend BaseEvent interface instead of duplicating properties
• Removed duplicate connection, queryRunner, and manager property definitions

src/subscriber/event/LoadEvent.ts


62. test/github-issues/4697/migration/1566560354098-UpdateContacts.ts 🧪 Tests +4/-4

Update migration to use manager instead of connection

• Updated migration method parameters from connection to manager
• Updated repository access from connection.getMongoRepository to manager.getMongoRepository

test/github-issues/4697/migration/1566560354098-UpdateContacts.ts


63. src/subscriber/event/TransactionCommitEvent.ts Refactoring +2/-21

Refactor TransactionCommitEvent to extend BaseEvent

• Refactored to extend BaseEvent interface instead of duplicating properties
• Removed duplicate property definitions

src/subscriber/event/TransactionCommitEvent.ts


64. src/subscriber/event/TransactionStartEvent.ts Refactoring +2/-21

Refactor TransactionStartEvent to extend BaseEvent

• Refactored to extend BaseEvent interface instead of duplicating properties
• Removed duplicate property definitions

src/subscriber/event/TransactionStartEvent.ts


65. src/subscriber/event/TransactionRollbackEvent.ts Refactoring +2/-21

Refactor TransactionRollbackEvent to extend BaseEvent

• Refactored to extend BaseEvent interface instead of duplicating properties
• Removed duplicate property definitions

src/subscriber/event/TransactionRollbackEvent.ts


66. src/driver/nativescript/NativescriptDriver.ts Refactoring +3/-5

Update NativescriptDriver constructor parameter

• Updated constructor parameter from connection to dataSource
• Removed redundant property assignments (inherited from parent class)

src/driver/nativescript/NativescriptDriver.ts


67. test/functional/schema-builder/add-column.test.ts 📦 Other +2/-4
• Removed connection parameter from ColumnMetadata constructor calls
• Simplified object literal syntax in constructor calls

test/functional/schema-builder/add-column.test.ts


68. docs/docs/data-source/4-data-source-api.md Additional files +1/-1

...

docs/docs/data-source/4-data-source-api.md


69. docs/docs/guides/8-migration-v1.md Additional files +10/-6

...

docs/docs/guides/8-migration-v1.md


70. src/data-source/DataSource.ts Additional files +2/-2

...

src/data-source/DataSource.ts


71. src/driver/capacitor/CapacitorDriver.ts Additional files +2/-2

...

src/driver/capacitor/CapacitorDriver.ts


72. src/driver/cordova/CordovaDriver.ts Additional files +2/-4

...

src/driver/cordova/CordovaDriver.ts


73. src/driver/expo/ExpoDriver.ts Additional files +2/-2

...

src/driver/expo/ExpoDriver.ts


74. src/driver/types/ReturningType.ts Additional files +1/-0

...

src/driver/types/ReturningType.ts


75. src/entity-manager/SqljsEntityManager.ts Additional files +3/-3

...

src/entity-manager/SqljsEntityManager.ts


76. src/logger/AbstractLogger.ts Additional files +1/-1

...

src/logger/AbstractLogger.ts


77. src/metadata-builder/RelationJoinColumnBuilder.ts Additional files +0/-1

...

src/metadata-builder/RelationJoinColumnBuilder.ts


78. src/metadata/IndexMetadata.ts Additional files +4/-7

...

src/metadata/IndexMetadata.ts


79. src/persistence/SubjectDatabaseEntityLoader.ts Additional files +1/-1

...

src/persistence/SubjectDatabaseEntityLoader.ts


80. src/persistence/tree/MaterializedPathSubjectExecutor.ts Additional files +1/-1

...

src/persistence/tree/MaterializedPathSubjectExecutor.ts


81. src/query-builder/JoinAttribute.ts Additional files +0/-12

...

src/query-builder/JoinAttribute.ts


82. src/query-builder/RelationQueryBuilder.ts Additional files +1/-1

...

src/query-builder/RelationQueryBuilder.ts


83. src/query-builder/RelationUpdater.ts Additional files +2/-2

...

src/query-builder/RelationUpdater.ts


84. src/query-builder/transformer/PlainObjectToDatabaseEntityTransformer.ts Additional files +1/-1

...

src/query-builder/transformer/PlainObjectToDatabaseEntityTransformer.ts


85. src/query-runner/QueryRunner.ts Additional files +8/-2

...

src/query-runner/QueryRunner.ts


86. src/repository/Repository.ts Additional files +2/-2

...

src/repository/Repository.ts


87. src/schema-builder/RdbmsSchemaBuilder.ts Additional files +0/-1

...

src/schema-builder/RdbmsSchemaBuilder.ts


88. src/util/TreeRepositoryUtils.ts Additional files +2/-2

...

src/util/TreeRepositoryUtils.ts


89. test/functional/relations/eager-relations/basic-eager-relations/basic-eager-relations.test.ts Additional files +1/-1

...

test/functional/relations/eager-relations/basic-eager-relations/basic-eager-relations.test.ts


90. test/github-issues/2693/issue-2693.test.ts Additional files +1/-1

...

test/github-issues/2693/issue-2693.test.ts


91. test/github-issues/2693/migration/0000000000003-InsertUser.ts Additional files +2/-1

...

test/github-issues/2693/migration/0000000000003-InsertUser.ts


92. test/github-issues/7087/migration/0000000000002-InsertUser.ts Additional files +1/-1

...

test/github-issues/7087/migration/0000000000002-InsertUser.ts


93. test/github-issues/7155/issue-7155.test.ts Additional files +1/-1

...

test/github-issues/7155/issue-7155.test.ts


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

qodo-free-for-open-source-projects bot commented Mar 20, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0) 📐 Spec deviations (0)

Grey Divider


Action required

1. Oracle driver alias missing🐞 Bug ✓ Correctness
Description
OracleDriver renames its connection field to dataSource but does not provide the deprecated
connection getter that other drivers expose for backward compatibility. Code that still reads
oracleDriver.connection will break specifically for Oracle while continuing to work for other
drivers that kept the alias.
Code

src/driver/oracle/OracleDriver.ts[R41-45]

/**
* Connection used by driver.
*/
-    connection: DataSource
+    dataSource: DataSource
Evidence
OracleDriver only exposes dataSource: DataSource and does not define a deprecated connection
accessor near the driver’s public properties, while other drivers (e.g., MySQL) explicitly keep `get
connection(): DataSource { return this.dataSource }` to preserve the old API shape during the
rename.

src/driver/oracle/OracleDriver.ts[36-60]
src/driver/mysql/MysqlDriver.ts[40-51]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`OracleDriver` was updated to store its owning `DataSource` in `dataSource`, but it does not expose the deprecated `connection` alias that other drivers provide. This creates an inconsistent API surface and breaks any code still using `driver.connection` for Oracle.
### Issue Context
Other drivers in this refactor keep a compatibility shim:

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Docs miss deprecated alias 🐞 Bug ⚙ Maintainability
Description
The migration guide claims only EntityManager has a deprecated getter for .connection, but this
PR also adds a deprecated EntityMetadata.connection getter. This can mislead users into expecting
.connection to be fully removed on EntityMetadata (or, conversely, not realizing it remains
available but deprecated).
Code

docs/docs/guides/8-migration-v1.md[298]

+The `connection` property in the `Driver`, `QueryRunner`, `EntityManager`, `QueryBuilder`, `EntityMetadata` and `*Event` classes was renamed to `dataSource`. For `EntityManager`, this change was announced in 0.3, but it was not actually implemented. To ease the transition, a deprecated getter was added that returns the same value as `dataSource`.
Evidence
EntityMetadata now explicitly keeps .connection as a deprecated getter returning .dataSource,
but the migration guide paragraph only calls out the deprecated getter behavior for EntityManager
while adding EntityMetadata to the renamed list.

docs/docs/guides/8-migration-v1.md[296-299]
src/metadata/EntityMetadata.ts[37-48]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The migration guide mentions a deprecated `.connection` getter only for `EntityManager`, but `EntityMetadata` also retains `.connection` via a deprecated getter.
### Issue Context
This PR adds `EntityMetadata` to the list of classes whose `.connection` was renamed to `.dataSource`, and the implementation includes a deprecated compatibility getter.
### Fix Focus Areas
- docs/docs/guides/8-migration-v1.md[296-299]
- src/metadata/EntityMetadata.ts[37-48]
### Suggested change
Amend the migration text to note that `EntityMetadata` (and any other affected classes, if applicable) also retains a deprecated `.connection` alias returning `.dataSource` to ease transition.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. as any on options.schema 📘 Rule violation ⚙ Maintainability
Description
The refactor retains an any cast when reading schema from dataSource.options, which bypasses
type-safety and can mask incorrect option shapes. This conflicts with the requirement to avoid
any-casts used to bypass type issues.
Code

src/metadata/EntityMetadata.ts[R997-998]

+        } else if (this.dataSource.options?.hasOwnProperty("schema")) {
+            this.schema = (this.dataSource.options as any).schema
Evidence
PR Compliance ID 4 disallows introducing/keeping any-casts that bypass types; the modified code
uses (this.dataSource.options as any).schema to access schema without a typed contract.

Rule 4: Remove AI-generated noise
src/metadata/EntityMetadata.ts[997-998]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A modified line accesses `schema` via `(this.dataSource.options as any).schema`, bypassing type safety.
## Issue Context
This PR refactors `connection` to `dataSource` and touches this code path, so it is an opportunity to keep type-safety rather than relying on `any`.
## Fix Focus Areas
- src/metadata/EntityMetadata.ts[997-998]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 23, 2026

Deploying typeorm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 82a0e56
Status: ✅  Deploy successful!
Preview URL: https://781735ff.typeorm.pages.dev
Branch Preview URL: https://refactor-connection-to-data-2ldk.typeorm.pages.dev

View logs

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 23, 2026

commit: 82a0e56

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

Persistent review updated to latest commit 3166444

@alumni alumni force-pushed the refactor/connection-to-data-source-events branch from 475ed62 to 7c86c5a Compare March 23, 2026 10:38
Base automatically changed from refactor/connection-to-data-source-events to master March 23, 2026 11:09
@alumni alumni force-pushed the refactor/connection-to-data-source-metadata branch from 3166444 to 82a0e56 Compare March 23, 2026 12:50
@sonarqubecloud
Copy link
Copy Markdown

@alumni alumni enabled auto-merge (squash) March 23, 2026 12:56
@qodo-free-for-open-source-projects
Copy link
Copy Markdown

Persistent review updated to latest commit 82a0e56

@alumni alumni merged commit 4457938 into master Mar 23, 2026
44 checks passed
@alumni alumni deleted the refactor/connection-to-data-source-metadata branch March 23, 2026 13:03
@github-actions github-actions bot added this to the 1.0 milestone Mar 23, 2026
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 73.38% (-0.003%) from 73.383%
when pulling 82a0e56 on refactor/connection-to-data-source-metadata
into 77c4216 on master.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Rename connection to dataSource in EntityManager, Repository, QueryBuilder, QueryRunner etc. Create deprecated alias for backwards-compatibility.

5 participants