Skip to content

Refactor for fuction that checks if db is system db#21639

Merged
allancascante merged 3 commits intomainfrom
dev/allancascante/profiler_refactor_system_dbs
Mar 18, 2026
Merged

Refactor for fuction that checks if db is system db#21639
allancascante merged 3 commits intomainfrom
dev/allancascante/profiler_refactor_system_dbs

Conversation

@allancascante
Copy link
Contributor

Description

Refactor to move logic that validates if a db in a connection is for a system db to an utils file.

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (npm run test)
  • Code follows contributing guidelines
  • Telemetry/logging updated if relevant
  • No regressions or UX breakage

Reviewers: Please read our reviewer guidelines

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors system-database detection into a shared utility so the profiler logic can consistently identify and exclude system DBs (master/tempdb/model/msdb) when prompting for an Azure/Fabric user database.

Changes:

  • Added systemDatabases constant and isSystemDatabase helper utility.
  • Updated ProfilerController to use the shared helper instead of an in-class implementation.
  • Added unit tests for the new utility and adjusted profiler controller unit tests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
extensions/mssql/test/unit/utils/databaseUtils.test.ts Adds unit tests validating systemDatabases and isSystemDatabase behavior.
extensions/mssql/test/unit/profiler/profilerController.test.ts Updates/clarifies Azure DB-selection-related test setup and comments.
extensions/mssql/src/utils/databaseUtils.ts Introduces shared isSystemDatabase helper backed by constants.
extensions/mssql/src/profiler/profilerController.ts Replaces inline system DB logic with shared helper.
extensions/mssql/src/constants/constants.ts Adds exported systemDatabases list used by the helper/tests.

You can also share your feedback on Copilot code review. Take the survey.

@allancascante allancascante linked an issue Mar 16, 2026 that may be closed by this pull request
17 tasks
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 16, 2026 22:43
@github-actions
Copy link

github-actions bot commented Mar 16, 2026

PR Changes

Category Target Branch PR Branch Difference
vscode-mssql VSIX 6438 KB 6438 KB ⚪ 0 KB ( 0% )
sql-database-projects VSIX 7060 KB 7060 KB ⚪ 0 KB ( 0% )
data-workspace VSIX 535 KB 535 KB ⚪ 0 KB ( 0% )

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors system-database detection into a shared utility so features (notably Profiler) use a single, consistent source of truth for identifying system DBs.

Changes:

  • Add systemDatabases constant and new isSystemDatabase helper in src/utils.
  • Update ProfilerController to use the shared helper instead of an internal method/constant.
  • Add unit tests for the new helper and adjust profiler controller unit tests for database-selection scenarios.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
extensions/mssql/src/constants/constants.ts Introduces systemDatabases as the centralized system DB list.
extensions/mssql/src/utils/databaseUtils.ts Adds isSystemDatabase() helper that uses systemDatabases.
extensions/mssql/src/profiler/profilerController.ts Replaces local system DB logic with shared isSystemDatabase() import.
extensions/mssql/test/unit/utils/databaseUtils.test.ts Adds unit coverage for systemDatabases and isSystemDatabase().
extensions/mssql/test/unit/profiler/profilerController.test.ts Updates test setup for Azure DB selection paths.

You can also share your feedback on Copilot code review. Take the survey.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.90%. Comparing base (1dd3adf) to head (155ed9b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #21639   +/-   ##
=======================================
  Coverage   72.90%   72.90%           
=======================================
  Files         331      332    +1     
  Lines       99035    99042    +7     
  Branches     5566     5566           
=======================================
+ Hits        72201    72208    +7     
  Misses      26834    26834           
Files with missing lines Coverage Δ
extensions/mssql/src/constants/constants.ts 100.00% <100.00%> (ø)
...xtensions/mssql/src/profiler/profilerController.ts 49.42% <100.00%> (-0.58%) ⬇️
extensions/mssql/src/utils/databaseUtils.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@aasimkhan30 aasimkhan30 left a comment

Choose a reason for hiding this comment

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

Thanks for making this change in a shared utility. Can you please make sure we don't have any existing code that does this and make it use this method?

@allancascante allancascante changed the title Refactor for is system db Refactor for fuction that checks if db is system db Mar 17, 2026
@allancascante allancascante merged commit be31037 into main Mar 18, 2026
6 of 7 checks passed
@allancascante allancascante deleted the dev/allancascante/profiler_refactor_system_dbs branch March 18, 2026 21:48
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.

[Feature Request]: Create database selector util

5 participants