Skip to content

chore: align master with v0.3 - #11912

Merged
michaelbromley merged 4 commits into
typeorm:masterfrom
gioboa:chore/align-with-v0.3
Jan 13, 2026
Merged

michaelbromley merged 4 commits into
typeorm:masterfrom
gioboa:chore/align-with-v0.3

Conversation

@gioboa

@gioboa gioboa commented Jan 11, 2026 •

Copy link
Copy Markdown
Collaborator

Description of change

This PR merges the current v0.3 branch with master.

Pull-Request Checklist

  • Code is up-to-date with the master branch

@pkg-pr-new

pkg-pr-new Bot commented Jan 11, 2026 •

Copy link
Copy Markdown
  • typeorm-sql-js-example

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

commit: 8d6c4ed

@gioboa
gioboa marked this pull request as ready for review January 11, 2026 14:58
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Date Handling Removed

The code removed Date-to-string conversion logic when processing query parameters. Previously, Date objects were explicitly converted using DateUtils.mixedDateToDatetimeString(). This removal may cause issues if the SAP HANA driver doesn't automatically handle Date objects correctly, potentially leading to incorrect date values or query failures.

    (key) => nativeParameters[key],
)
Query Builder Reuse

The query builder is now stored in a variable qb before chaining methods, but the variable is declared without const/let/var. This appears to be incomplete refactoring where the assignment statement is missing, which would cause a runtime error.

const qb = this.createQueryBuilder()
    .insert()
    .into(target)
    .values(entities)
Unused Parameter

The isReturningSqlSupported method now accepts a returningType parameter but doesn't use it in the implementation. While other drivers prefix it with underscore to indicate intentional non-use, this driver should follow the same pattern for consistency or actually use the parameter if different returning types require different handling.

isReturningSqlSupported(returningType: ReturningType): boolean {
    if (
        this.options.options &&
        this.options.options.disableOutputReturning
    ) {
        return false

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jan 11, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Disallow returning clause in updateAll

In the updateAll method in EntityManager.ts, throw an error if options.returning
is provided to prevent its use with an operation that has no WHERE clause.

src/entity-manager/EntityManager.ts [833-845]

 updateAll<Entity extends ObjectLiteral>(
     target: EntityTarget<Entity>,
     partialEntity: QueryDeepPartialEntity<Entity>,
     options?: UpdateOptions,
 ): Promise<UpdateResult> {
+    if (options?.returning) {
+        throw new TypeORMError(
+            `A returning clause is not supported for updateAll. Please use the update method if you need a returning clause.`,
+        )
+    }
     const qb = this.createQueryBuilder().update(target).set(partialEntity)
-
-    if (options?.returning !== undefined) {
-        qb.returning(options.returning)
-    }
 
     return qb.execute()
 }
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion improves safety by preventing the potentially misleading use of a returning clause with updateAll, which could lead to unexpected behavior for developers.

Medium
General
Remove fallback to deprecated property

In SapDriver.ts, remove the fallback to the deprecated
this.options.pool?.requestTimeout when setting the maxWaitTimeoutIfPoolExhausted
option.

src/driver/sap/SapDriver.ts [294-297]

 maxWaitTimeoutIfPoolExhausted:
-    this.options.pool?.maxWaitTimeoutIfPoolExhausted ??
-    this.options.pool?.requestTimeout ??
-    0,
+    this.options.pool?.maxWaitTimeoutIfPoolExhausted ?? 0,
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly proposes removing the fallback to the deprecated requestTimeout property, which improves code clarity and aligns with the PR's intent to introduce a new property.

Low
  • More

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jan 11, 2026 •

Copy link
Copy Markdown

Code Review by Qodo (Alpha)

(Review updated until commit 8d6c4ed)

🐞 Bugs (0) 📘 Rule Violations (0) 📎 Requirement Gaps (0) 💡 Suggestions (0)

Grey Divider

Great, No Issues Found!

Qodo reviewed your code and found no material issues that require review

Grey Divider


Previous review results

Results up to commit c1b0a14


🐞 Bugs (1) 📘 Rule Violations (0) 📎 Requirement Gaps (0) 💡 Suggestions (0)

Grey Divider
Remediation Recommended
1. Missing Test Coverage for SAP Driver 🐞 Bug
Description
• A new date-parameters test was added but does not include the SAP driver in its test suite
• The SAP driver had Date parameter conversion logic removed in this PR
• Without test coverage, there's no validation that Date parameters work correctly with the updated
  SAP driver and @sap/hana-client 2.27+

reliability

Code

test/functional/query-builder/parameters/date-parameters.test.ts[19]

+            })),
Evidence
The new date-parameters test explicitly excludes SAP driver from testing (only tests postgres,
mysql, mssql, spanner). Meanwhile, the SAP driver had significant changes to date parameter handling
- the Date-to-string conversion was removed from escapeQueryWithParameters(). This leaves the SAP
driver's date parameter handling untested after a breaking change.

test/functional/query-builder/parameters/date-parameters.test.ts[15-19]
test/functional/repository/returning/repository-returning.test.ts[17-20]
src/driver/sap/SapDriver.ts[412-413]

Agent Prompt
## Issue Description
The new date-parameters test does not include the SAP driver, leaving date parameter handling untested after significant changes to the SAP driver&#x27;s parameter escaping logic.

## Issue Context
In this PR:
1. The SAP driver removed Date-to-string conversion from `escapeQueryWithParameters()` (lines 408-417)
2. The @sap/hana-client was upgraded from 2.26.26 to 2.27.19
3. A new test file `test/functional/query-builder/parameters/date-parameters.test.ts` was added
4. However, the test does not specify `enabledDrivers`, meaning it runs on all drivers by default, but there&#x27;s no explicit validation that SAP is included

The test at lines 47-49 passes Date objects as query parameters, which is exactly what needs validation for SAP driver.

## Fix Focus Areas
Either:
1. Verify that the test runs against SAP driver (check test execution logs), OR
2. Add explicit test coverage for SAP driver date parameters

- test/functional/query-builder/parameters/date-parameters.test.ts[15-20]
- test/functional/query-builder/parameters/date-parameters.test.ts[47-49]

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


Grey Divider
Results up to commit 73442f3


🐞 Bugs (2) 📘 Rule Violations (0) 📎 Requirement Gaps (0) 💡 Suggestions (0)

Grey Divider
Action Required
1. Driver Interface Signature Mismatch 🐞 Bug
Description
• Five driver implementations have not been updated to match the new Driver interface signature for
  isReturningSqlSupported()
• The interface now requires a ReturningType parameter, but these drivers still use the old
  signature without parameters
• This creates a TypeScript interface implementation mismatch that will cause compilation errors in
  strict mode
• The PR updated some drivers (PostgresDriver, OracleDriver, CockroachDriver, SpannerDriver,
  SqlServerDriver) but missed others

correctness

Code

src/driver/cockroachdb/CockroachDriver.ts[20]

+import { Driver, ReturningType } from "../Driver"
Evidence
The Driver interface at src/driver/Driver.ts:277 defines isReturningSqlSupported(returningType:
ReturningType): boolean. The PR updates some drivers to accept this parameter (as shown in the
diff), but five drivers remain unchanged: SapDriver (line 840), AbstractSqliteDriver (line 886),
ReactNativeDriver (line 884), MongoDriver (line 468), and AuroraMysqlDriver (line 973). These
drivers still have the old signature isReturningSqlSupported(): boolean without the required
parameter, creating a TypeScript interface implementation violation.

src/driver/Driver.ts[277-277]
src/driver/sap/SapDriver.ts[840-842]
src/driver/sqlite-abstract/AbstractSqliteDriver.ts[886-888]
src/driver/react-native/ReactNativeDriver.ts[884-886]
src/driver/mongodb/MongoDriver.ts[468-470]
src/driver/aurora-mysql/AuroraMysqlDriver.ts[973-975]

Agent Prompt
# Issue Description
Five driver implementations have not been updated to match the new Driver interface signature. The interface now requires `isReturningSqlSupported(returningType: ReturningType): boolean` but these drivers still use the old signature without the parameter.

# Issue Context
The PR introduces a ReturningType parameter to distinguish between different SQL operations (insert, update, delete) that support RETURNING clauses. Some drivers were updated but five were missed.

# Fix Focus Areas
Update the method signature in each of the following files to accept the ReturningType parameter (use underscore prefix if the parameter is unused):

- src/driver/sap/SapDriver.ts[840-842]
- src/driver/sqlite-abstract/AbstractSqliteDriver.ts[886-888]
- src/driver/react-native/ReactNativeDriver.ts[884-886]
- src/driver/mongodb/MongoDriver.ts[468-470]
- src/driver/aurora-mysql/AuroraMysqlDriver.ts[973-975]

Change from:
```typescript
isReturningSqlSupported(): boolean {
   return false
}
```

To:
```typescript
isReturningSqlSupported(_returningType: ReturningType): boolean {
   return false
}
```

Also add the import at the top of each file:
```typescript
import { Driver, ReturningType } from &quot;../Driver&quot;
```

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



Remediation Recommended
2. Backward Compatibility Break for requestTimeout 🐞 Bug
Description
• The deprecated pool.requestTimeout option is now used as a fallback for the new
  maxWaitTimeoutIfPoolExhausted option
• This changes the behavior: requestTimeout previously had no effect (marked as obsolete with no
  alternative), but now it will be used if maxWaitTimeoutIfPoolExhausted is not set
• Users relying on requestTimeout being ignored may experience unexpected connection timeout
  behavior
• The deprecation message was updated but doesn't warn about the behavioral change

reliability

Code

src/driver/sap/SapDriver.ts[R294-297]

+            maxWaitTimeoutIfPoolExhausted:
+                this.options.pool?.maxWaitTimeoutIfPoolExhausted ??
+                this.options.pool?.requestTimeout ??
+                0,
Evidence
The code at lines 294-297 shows maxWaitTimeoutIfPoolExhausted now falls back to requestTimeout if
not set. The documentation change at src/driver/sap/SapConnectionOptions.ts:87 updates the
deprecation message from 'Obsolete, no alternative exists' to 'Use maxWaitTimeoutIfPoolExhausted
instead', indicating requestTimeout was previously non-functional. However, the new code gives it
functionality as a fallback, which is a behavioral change that could affect existing configurations.

src/driver/sap/SapDriver.ts[294-297]
src/driver/sap/SapConnectionOptions.ts[87-87]

Agent Prompt
# Issue Description
The deprecated pool.requestTimeout option now has functional behavior as a fallback for maxWaitTimeoutIfPoolExhausted, but it was previously marked as obsolete with no effect. This is a breaking change for users who may have set requestTimeout expecting it to be ignored.

# Issue Context
The deprecation message changed from &#x27;Obsolete, no alternative exists&#x27; to &#x27;Use maxWaitTimeoutIfPoolExhausted instead&#x27;, and the implementation now uses requestTimeout as a fallback value. This gives functionality to a previously non-functional deprecated option.

# Fix Focus Areas
Choose one of these approaches:

**Option 1 (Recommended): Remove the fallback**
- src/driver/sap/SapDriver.ts[294-297]

Change to:
```typescript
maxWaitTimeoutIfPoolExhausted:
   this.options.pool?.maxWaitTimeoutIfPoolExhausted ?? 0,
```

**Option 2: Add deprecation warning**
- src/driver/sap/SapDriver.ts[294-297]

Add a warning log before the assignment:
```typescript
if (this.options.pool?.requestTimeout &amp;&amp; !this.options.pool?.maxWaitTimeoutIfPoolExhausted) {
   this.connection.logger.logSchemaBuild(
       &#x27;pool.requestTimeout is deprecated and will be removed in a future version. Use pool.maxWaitTimeoutIfPoolExhausted instead.&#x27;
   )
}
```

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


Grey Divider
Qodo Logo

@gioboa gioboa left a comment •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@naorpeled I enabled your test by renaming the file and here is failing. Can you have a look at it?

Fixed

@gioboa
gioboa marked this pull request as draft January 11, 2026 15:41
@gioboa
gioboa marked this pull request as ready for review January 13, 2026 12:06
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Date handling removed

The PR removes Date-to-string conversion logic in escapeQueryWithParameters method. Previously, Date objects were converted to datetime strings using DateUtils.mixedDateToDatetimeString. This removal may cause issues if the SAP HANA driver expects dates in a specific string format rather than native Date objects. Verify that the driver handles Date objects correctly without explicit conversion.

    (key) => nativeParameters[key],
)

if (!parameters || !Object.keys(parameters).length)
    return [sql, escapedParameters]

sql = sql.replace(
    /:(\.\.\.)?([A-Za-z0-9_.]+)/g,
    (full, isArray: string, key: string): string => {
        if (!parameters.hasOwnProperty(key)) {
            return full
        }

        const value: any = parameters[key]

        if (isArray) {
            return value
                .map((v: any) => {
                    escapedParameters.push(v)
                    return this.createParameter(
                        key,
                        escapedParameters.length - 1,
                    )
                })
                .join(", ")
        }

        if (typeof value === "function") {
            return value()
        }

        escapedParameters.push(value)
        return this.createParameter(key, escapedParameters.length - 1)
Incomplete refactoring

The upsert method creates a QueryBuilder (qb) but the original code pattern suggests it should chain .execute() at the end. The new code adds conditional returning logic and calls qb.execute(), but the variable assignment pattern at line 744 looks incomplete - it assigns to qb but doesn't return immediately, which may cause issues with the control flow.

const qb = this.createQueryBuilder()
    .insert()
    .into(target)
    .values(entities)
    .orUpdate(
        [...conflictColumns, ...overwriteColumns].map(
            (col) => col.databaseName,
        ),
        conflictColumns.map((col) => col.databaseName),
        {
            skipUpdateIfNoValuesChanged:
                options.skipUpdateIfNoValuesChanged,
            indexPredicate: options.indexPredicate,
            upsertType:
                options.upsertType ||
                this.connection.driver.supportedUpsertTypes[0],
        },
    )

if (options.returning !== undefined) {
    qb.returning(options.returning)
}

return qb.execute()
Unused parameter

The isReturningSqlSupported method now accepts a returningType parameter but doesn't use it in the implementation. While this may be for interface consistency, verify whether SQL Server should differentiate behavior based on the returning type (insert vs update operations).

isReturningSqlSupported(returningType: ReturningType): boolean {
    if (
        this.options.options &&
        this.options.options.disableOutputReturning
    ) {
        return false

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Reflect SQL Server returning capabilities accurately

In SqlServerDriver, modify isReturningSqlSupported to return false when
returningType is upsert to accurately reflect the driver's capabilities and
prevent runtime errors.

src/driver/sqlserver/SqlServerDriver.ts [918-926]

 isReturningSqlSupported(returningType: ReturningType): boolean {
     if (
         this.options.options &&
         this.options.options.disableOutputReturning
     ) {
         return false
     }
+
+    if (returningType === "upsert") {
+        return false
+    }
+
     return true
 }
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that using returning with upsert on SQL Server is not supported by the current implementation and would cause a runtime error, so disabling it is the correct approach.

Medium
General
Avoid using a deprecated fallback option

In SapDriver, remove the fallback to the deprecated requestTimeout property when
setting maxWaitTimeoutIfPoolExhausted to avoid relying on obsolete options.

src/driver/sap/SapDriver.ts [294-297]

 maxWaitTimeoutIfPoolExhausted:
-    this.options.pool?.maxWaitTimeoutIfPoolExhausted ??
-    this.options.pool?.requestTimeout ??
-    0,
+    this.options.pool?.maxWaitTimeoutIfPoolExhausted ?? 0,
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly points out that using a deprecated property as a fallback is not ideal, and removing it improves code quality and future-proofing by providing a smoother migration path for users.

Low
  • More

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit c1b0a14

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit c1b0a14

@alumni

alumni commented Jan 13, 2026

Copy link
Copy Markdown
Collaborator

We should merge without squashing if we merge this.

Was wondering whether we should cherry pick the 3 commits that are actually relevant for v1 (11d9767, b4e2ad2, 5153436), so we pollute the changelog 🤷🏻

@gioboa gioboa left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yep, let me do that. I'll take the commit that is fixing the tests

@gioboa
gioboa force-pushed the chore/align-with-v0.3 branch from c1b0a14 to 81c3753 Compare January 13, 2026 12:34
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@gioboa
gioboa force-pushed the chore/align-with-v0.3 branch from 81c3753 to 8d6c4ed Compare January 13, 2026 12:38
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 81c3753

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 8d6c4ed

@michaelbromley
michaelbromley merged commit 75f4463 into typeorm:master Jan 13, 2026
38 checks passed
@pkuczynski pkuczynski added this to the 1.0 milestone Mar 8, 2026
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.

5 participants