Skip to content

refactor(query-builder): replace deprecated substr with modern alternatives - #12149

Merged
pkuczynski merged 8 commits into
masterfrom
worktree-agent-a4e93fb6
Mar 12, 2026
Merged

pkuczynski merged 8 commits into
masterfrom
worktree-agent-a4e93fb6

Conversation

@naorpeled

@naorpeled naorpeled commented Mar 8, 2026 •

Copy link
Copy Markdown
Member

Description

String.substr is deprecated, so I've updated the code to use newer functions.

Copilot AI review requested due to automatic review settings March 8, 2026 21:28
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Review Summary by Qodo

Replace deprecated substr with modern string methods

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Replace deprecated substr() with modern string methods
• Use startsWith() and endsWith() for prefix/suffix checks
• Use bracket notation for single character access
• Improve code readability and maintainability
Diagram
flowchart LR
  A["substr method calls"] -- "refactor to modern alternatives" --> B["startsWith/endsWith/bracket notation"]
  B --> C["Improved code quality"]
Loading

Grey Divider

File Changes

1. src/query-builder/QueryBuilder.ts ✨ Enhancement +1/-2

Replace substr with startsWith/endsWith

• Replace entityTarget.substr(0, 1) with entityTarget.startsWith("(")
• Replace entityTarget.substr(-1) with entityTarget.endsWith(")")
• Simplify subquery detection logic

src/query-builder/QueryBuilder.ts


2. src/query-builder/SelectQueryBuilder.ts ✨ Enhancement +1/-1

Replace substr with bracket notation

• Replace this.conditions.substr(0, 1) with this.conditions[0]
• Use bracket notation for single character access
• Maintain same logic for condition wrapping

src/query-builder/SelectQueryBuilder.ts


Grey Divider

Qodo Logo

@pkg-pr-new

pkg-pr-new Bot commented Mar 8, 2026 •

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

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

commit: aa1a90a

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

qodo-free-for-open-source-projects Bot commented Mar 8, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Deprecated substr remains 🐞 Bug ⛯ Reliability
Description
This PR updates two call sites away from String.substr, but many other substr() usages remain in
core modules, so the deprecation cleanup is incomplete and inconsistent. If this change was intended
to eliminate substr deprecation warnings project-wide, it will not achieve that.
Code

src/query-builder/QueryBuilder.ts[R673-674]

           const isSubquery =
-                    entityTarget.substr(0, 1) === "(" &&
-                    entityTarget.substr(-1) === ")"
+                    entityTarget.startsWith("(") && entityTarget.endsWith(")")
Evidence
The PR updates QueryBuilder.createFromAlias to use startsWith/endsWith, demonstrating the
intended refactor direction, but other core files still call substr(), including within the
query-builder layer and common utilities/migrations. This shows the refactor is not comprehensive
and leaves the deprecated API in active use.

src/query-builder/QueryBuilder.ts[671-684]
src/query-builder/JoinAttribute.ts[126-150]
src/util/StringUtils.ts[40-60]
src/migration/MigrationExecutor.ts[582-590]

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 PR claims to replace deprecated `String.substr`, but it only updates two occurrences; many other `substr()` calls remain, so the deprecation cleanup is incomplete.
### Issue Context
TypeScript marks `String.substr` as deprecated in its lib typings, so lingering usages can keep IDE/CI deprecation noise and create inconsistent string handling patterns.
### Fix Focus Areas
- src/query-builder/JoinAttribute.ts[126-150]
- src/util/StringUtils.ts[40-60]
- src/migration/MigrationExecutor.ts[582-590]

ⓘ 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

Grey Divider

Previous review results

Review updated until commit aa1a90a

Results up to commit c9aa5cc


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

Grey Divider
Remediation recommended
1. Deprecated substr remains 🐞 Bug ⛯ Reliability
Description
This PR updates two call sites away from String.substr, but many other substr() usages remain in
core modules, so the deprecation cleanup is incomplete and inconsistent. If this change was intended
to eliminate substr deprecation warnings project-wide, it will not achieve that.
Code

src/query-builder/QueryBuilder.ts[R673-674]

            const isSubquery =
-                    entityTarget.substr(0, 1) === "(" &&
-                    entityTarget.substr(-1) === ")"
+                    entityTarget.startsWith("(") && entityTarget.endsWith(")")
Evidence
The PR updates QueryBuilder.createFromAlias to use startsWith/endsWith, demonstrating the
intended refactor direction, but other core files still call substr(), including within the
query-builder layer and common utilities/migrations. This shows the refactor is not comprehensive
and leaves the deprecated API in active use.

src/query-builder/QueryBuilder.ts[671-684]
src/query-builder/JoinAttribute.ts[126-150]
src/util/StringUtils.ts[40-60]
src/migration/MigrationExecutor.ts[582-590]

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 PR claims to replace deprecated `String.substr`, but it only updates two occurrences; many other `substr()` calls remain, so the deprecation cleanup is incomplete.
### Issue Context
TypeScript marks `String.substr` as deprecated in its lib typings, so lingering usages can keep IDE/CI deprecation noise and create inconsistent string handling patterns.
### Fix Focus Areas
- src/query-builder/JoinAttribute.ts[126-150]
- src/util/StringUtils.ts[40-60]
- src/migration/MigrationExecutor.ts[582-590]

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


Grey Divider Grey Divider
Results up to commit d8116c8


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

Grey Divider
Remediation recommended
1. Deprecated substr remains 🐞 Bug ⛯ Reliability
Description
This PR updates two call sites away from String.substr, but many other substr() usages remain in
core modules, so the deprecation cleanup is incomplete and inconsistent. If this change was intended
to eliminate substr deprecation warnings project-wide, it will not achieve that.
Code

src/query-builder/QueryBuilder.ts[R673-674]

             const isSubquery =
-                    entityTarget.substr(0, 1) === "(" &&
-                    entityTarget.substr(-1) === ")"
+                    entityTarget.startsWith("(") && entityTarget.endsWith(")")
Evidence
The PR updates QueryBuilder.createFromAlias to use startsWith/endsWith, demonstrating the
intended refactor direction, but other core files still call substr(), including within the
query-builder layer and common utilities/migrations. This shows the refactor is not comprehensive
and leaves the deprecated API in active use.

src/query-builder/QueryBuilder.ts[671-684]
src/query-builder/JoinAttribute.ts[126-150]
src/util/StringUtils.ts[40-60]
src/migration/MigrationExecutor.ts[582-590]

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 PR claims to replace deprecated `String.substr`, but it only updates two occurrences; many other `substr()` calls remain, so the deprecation cleanup is incomplete.
### Issue Context
TypeScript marks `String.substr` as deprecated in its lib typings, so lingering usages can keep IDE/CI deprecation noise and create inconsistent string handling patterns.
### Fix Focus Areas
- src/query-builder/JoinAttribute.ts[126-150]
- src/util/StringUtils.ts[40-60]
- src/migration/MigrationExecutor.ts[582-590]

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


Grey Divider Grey Divider
Results up to commit e2ba89d


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

Grey Divider
Remediation recommended
1. Deprecated substr remains 🐞 Bug ⛯ Reliability
Description
This PR updates two call sites away from String.substr, but many other substr() usages remain in
core modules, so the deprecation cleanup is incomplete and inconsistent. If this change was intended
to eliminate substr deprecation warnings project-wide, it will not achieve that.
Code

src/query-builder/QueryBuilder.ts[R673-674]

              const isSubquery =
-                    entityTarget.substr(0, 1) === "(" &&
-                    entityTarget.substr(-1) === ")"
+                    entityTarget.startsWith("(") && entityTarget.endsWith(")")
Evidence
The PR updates QueryBuilder.createFromAlias to use startsWith/endsWith, demonstrating the
intended refactor direction, but other core files still call substr(), including within the
query-builder layer and common utilities/migrations. This shows the refactor is not comprehensive
and leaves the deprecated API in active use.

src/query-builder/QueryBuilder.ts[671-684]
src/query-builder/JoinAttribute.ts[126-150]
src/util/StringUtils.ts[40-60]
src/migration/MigrationExecutor.ts[582-590]

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 PR claims to replace deprecated `String.substr`, but it only updates two occurrences; many other `substr()` calls remain, so the deprecation cleanup is incomplete.
### Issue Context
TypeScript marks `String.substr` as deprecated in its lib typings, so lingering usages can keep IDE/CI deprecation noise and create inconsistent string handling patterns.
### Fix Focus Areas
- src/query-builder/JoinAttribute.ts[126-150]
- src/util/StringUtils.ts[40-60]
- src/migration/MigrationExecutor.ts[582-590]

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


Grey Divider Grey Divider
Results up to commit ce81355


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

Grey Divider
Remediation recommended
1. Deprecated substr remains 🐞 Bug ⛯ Reliability
Description
This PR updates two call sites away from String.substr, but many other substr() usages remain in
core modules, so the deprecation cleanup is incomplete and inconsistent. If this change was intended
to eliminate substr deprecation warnings project-wide, it will not achieve that.
Code

src/query-builder/QueryBuilder.ts[R673-674]

               const isSubquery =
-                    entityTarget.substr(0, 1) === "(" &&
-                    entityTarget.substr(-1) === ")"
+                    entityTarget.startsWith("(") && entityTarget.endsWith(")")
Evidence
The PR updates QueryBuilder.createFromAlias to use startsWith/endsWith, demonstrating the
intended refactor direction, but other core files still call substr(), including within the
query-builder layer and common utilities/migrations. This shows the refactor is not comprehensive
and leaves the deprecated API in active use.

src/query-builder/QueryBuilder.ts[671-684]
src/query-builder/JoinAttribute.ts[126-150]
src/util/StringUtils.ts[40-60]
src/migration/MigrationExecutor.ts[582-590]

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 PR claims to replace deprecated `String.substr`, but it only updates two occurrences; many other `substr()` calls remain, so the deprecation cleanup is incomplete.
### Issue Context
TypeScript marks `String.substr` as deprecated in its lib typings, so lingering usages can keep IDE/CI deprecation noise and create inconsistent string handling patterns.
### Fix Focus Areas
- src/query-builder/JoinAttribute.ts[126-150]
- src/util/StringUtils.ts[40-60]
- src/migration/MigrationExecutor.ts[582-590]

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


Grey Divider Grey Divider
Results up to commit 80f6b21


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

Grey Divider
Remediation recommended
1. Deprecated substr remains 🐞 Bug ⛯ Reliability
Description
This PR updates two call sites away from String.substr, but many other substr() usages remain in
core modules, so the deprecation cleanup is incomplete and inconsistent. If this change was intended
to eliminate substr deprecation warnings project-wide, it will not achieve that.
Code

src/query-builder/QueryBuilder.ts[R673-674]

                const isSubquery =
-                    entityTarget.substr(0, 1) === "(" &&
-                    entityTarget.substr(-1) === ")"
+                    entityTarget.startsWith("(") && entityTarget.endsWith(")")
Evidence
The PR updates QueryBuilder.createFromAlias to use startsWith/endsWith, demonstrating the
intended refactor direction, but other core files still call substr(), including within the
query-builder layer and common utilities/migrations. This shows the refactor is not comprehensive
and leaves the deprecated API in active use.

src/query-builder/QueryBuilder.ts[671-684]
src/query-builder/JoinAttribute.ts[126-150]
src/util/StringUtils.ts[40-60]
src/migration/MigrationExecutor.ts[582-590]

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 PR claims to replace deprecated `String.substr`, but it only updates two occurrences; many other `substr()` calls remain, so the deprecation cleanup is incomplete.

### Issue Context
TypeScript marks `String.substr` as deprecated in its lib typings, so lingering usages can keep IDE/CI deprecation noise and create inconsistent string handling patterns.

### Fix Focus Areas
- src/query-builder/JoinAttribute.ts[126-150]
- src/util/StringUtils.ts[40-60]
- src/migration/MigrationExecutor.ts[582-590]

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


Grey Divider Grey Divider
Results up to commit 52168e9


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review Grey Divider Grey Divider
Results up to commit f347bdc


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review Grey Divider Grey Divider
Results up to commit 53458c3


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review Grey Divider Grey Divider
Results up to commit d333731


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review Grey Divider Grey Divider
Results up to commit 3e5faca


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review Grey Divider Grey Divider
Results up to commit b95b465


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes two usages of the deprecated String.prototype.substr() method in the query builder code, replacing them with startsWith()/endsWith() in QueryBuilder.ts and bracket notation in SelectQueryBuilder.ts. The substr method has been deprecated in favor of substring or other modern string APIs.

Changes:

  • Replace substr(0, 1) and substr(-1) with startsWith("(") and endsWith(")") in QueryBuilder.ts
  • Replace substr(0, 1) with bracket access [0] in SelectQueryBuilder.ts

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/query-builder/QueryBuilder.ts Replaced substr(0, 1) / substr(-1) with startsWith() / endsWith() for subquery detection
src/query-builder/SelectQueryBuilder.ts Replaced substr(0, 1) with bracket notation [0] for first-character check

Comment thread src/query-builder/SelectQueryBuilder.ts Resolved
@naorpeled
naorpeled requested a review from pkuczynski March 8, 2026 21:33
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 3e5faca

@coveralls

coveralls commented Mar 8, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 74.765%. remained the same
when pulling ce81355 on worktree-agent-a4e93fb6
into 9aafb04 on master.

Comment thread src/query-builder/SelectQueryBuilder.ts Resolved
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit d333731

@naorpeled
naorpeled force-pushed the worktree-agent-a4e93fb6 branch from d333731 to 53458c3 Compare March 9, 2026 00:07
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 53458c3

@naorpeled
naorpeled enabled auto-merge (squash) March 9, 2026 00:08
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 9, 2026 •

Copy link
Copy Markdown

Deploying typeorm with  Cloudflare Pages  Cloudflare Pages

Latest commit: aa1a90a
Status: ✅  Deploy successful!
Preview URL: https://4b472d3f.typeorm.pages.dev
Branch Preview URL: https://worktree-agent-a4e93fb6.typeorm.pages.dev

View logs

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

Copy link
Copy Markdown

Persistent review updated to latest commit f347bdc

@naorpeled
naorpeled disabled auto-merge March 9, 2026 18:46
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 52168e9

@naorpeled
naorpeled enabled auto-merge (squash) March 9, 2026 19:02
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

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

Grey Divider

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

Grey Divider

Grey Divider

Previous review results

Review updated until commit 5f1944f

Results up to commit 52168e9


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review Grey Divider Grey Divider
Results up to commit f347bdc


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review Grey Divider Grey Divider
Results up to commit 53458c3


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review Grey Divider Grey Divider
Results up to commit d333731


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review Grey Divider Grey Divider
Results up to commit 3e5faca


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review Grey Divider Grey Divider
Results up to commit b95b465


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

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

@naorpeled
naorpeled added this pull request to the merge queue Mar 9, 2026
@naorpeled
naorpeled removed this pull request from the merge queue due to a manual request Mar 9, 2026
@naorpeled
naorpeled added this pull request to the merge queue Mar 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Mar 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Mar 10, 2026
@gioboa
gioboa added this pull request to the merge queue Mar 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Mar 10, 2026
@naorpeled
naorpeled enabled auto-merge (squash) March 10, 2026 23:08
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 80f6b21

@naorpeled
naorpeled disabled auto-merge March 10, 2026 23:24
@naorpeled
naorpeled enabled auto-merge (squash) March 10, 2026 23:24
@naorpeled
naorpeled force-pushed the worktree-agent-a4e93fb6 branch from 80f6b21 to ce81355 Compare March 10, 2026 23:32
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit ce81355

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

Copy link
Copy Markdown

Persistent review updated to latest commit e2ba89d

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

Copy link
Copy Markdown

Persistent review updated to latest commit d8116c8

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

Copy link
Copy Markdown

Persistent review updated to latest commit c9aa5cc

@pkuczynski
pkuczynski disabled auto-merge March 12, 2026 15:56
@pkuczynski
pkuczynski enabled auto-merge (squash) March 12, 2026 15:56
@sonarqubecloud

Copy link
Copy Markdown

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

Copy link
Copy Markdown

Persistent review updated to latest commit aa1a90a

@pkuczynski
pkuczynski merged commit 3b47198 into master Mar 12, 2026
39 checks passed
@pkuczynski
pkuczynski deleted the worktree-agent-a4e93fb6 branch March 12, 2026 20:12
@github-actions github-actions Bot added this to the 1.0 milestone Mar 12, 2026
@Cprakhar Cprakhar mentioned this pull request Apr 2, 2026
1 of 4 tasks
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.

6 participants