Refactor for fuction that checks if db is system db#21639
Refactor for fuction that checks if db is system db#21639allancascante merged 3 commits intomainfrom
Conversation
…a system db to an utils file
There was a problem hiding this comment.
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
systemDatabasesconstant andisSystemDatabasehelper utility. - Updated
ProfilerControllerto 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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
PR Changes
|
There was a problem hiding this comment.
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
systemDatabasesconstant and newisSystemDatabasehelper insrc/utils. - Update
ProfilerControllerto 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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
aasimkhan30
left a comment
There was a problem hiding this comment.
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?
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
npm run test)Reviewers: Please read our reviewer guidelines